PyQt5: QKeySequence.StandardKey.* peculiar equality comparison

Ales Erjavec ales.erjavec324 at gmail.com
Tue Feb 1 13:46:12 GMT 2022


Hi,

`PyQt5.QtGui.QKeySequence.StandardKey` members do not compare equally
if accessed as `StandardKey` members multiple times.

```
from PyQt5.QtGui import QKeySequence

Cancel = QKeySequence.StandardKey.Cancel
assert Cancel == Cancel  # this works
assert QKeySequence.Cancel == QKeySequence.Cancel  # this works
assert QKeySequence.StandardKey.Cancel ==
QKeySequence.StandardKey.Cancel  # this does not
```
sip.enumtypes seem to create new instances when accessed from the
type, but other enums
seem to work correctly i.e. have defined equality.

This might be due to
```
bool operator==(QKeyEvent *e, QKeySequence::StandardKey key);
bool operator==(QKeySequence::StandardKey key, QKeyEvent *e);
```
overloads defined in qevent.sip

OS: Linux
Python: 3.10.1
PyQt5: 5.15.6

Thanks.


More information about the PyQt mailing list