PyQt5: QKeySequence.StandardKey.* peculiar equality comparison

Phil Thompson phil at riverbankcomputing.com
Sat Feb 26 14:33:05 GMT 2022


On 01/02/2022 13:46, Ales Erjavec wrote:
> 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.

Fixed in the next SIP snapshot.

Thanks,
Phil


More information about the PyQt mailing list