PyQt6: QEvent.type() returns int instead of QEvent.Type
Phil Thompson
phil at riverbankcomputing.com
Tue May 17 09:26:07 BST 2022
On 16/05/2022 16:31, Florian Bruhin wrote:
> On Mon, May 16, 2022 at 05:14:28PM +0200, Florian Bruhin wrote:
>> On Mon, May 16, 2022 at 09:45:05AM +0100, Phil Thompson wrote:
>> > On the local PyPI server is an sdist for PyQt6-sip v13.4.0 which implements
>> > the support for missing enum members. The current PyQt6 snapshot requires
>> > this version.
>>
>> Thanks! Something still seems odd about IntEnum support though, e.g.
>> with Qt.Key:
>>
>> >>> from PyQt6.QtGui import QKeySequence
>> >>> key = QKeySequence("\x80")[0].key()
>> >>> key
>> <Key.128: 128>
>> >>> type(key)
>> <enum 'Key'>
>> >>> type(key).__mro__
>> (<enum 'Key'>, <enum 'IntEnum'>, <class 'int'>, <enum 'Enum'>,
>> <class 'object'>)
>> >>> key > 1
>> False
>>
>> but I'd expect that to be True, just like a normal Qt.Key member:
>>
>> >>> from PyQt6.QtCore import Qt
>> >>> type(Qt.Key.Key_A)
>> <enum 'Key'>
>> >>> Qt.Key.Key_A > 1
>> True
>
> To be more exact: The value always seems to be equal to 0, actually:
>
> >>> key
> <Key.128: 128>
> >>> key == 0
> True
> >>> int(key)
> 0
I've uploaded a fixed PyQt6-sip sdist.
Thanks,
Phil
More information about the PyQt
mailing list