PyQt6: QEvent.type() returns int instead of QEvent.Type

Florian Bruhin me at the-compiler.org
Mon May 16 16:31:37 BST 2022


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

Florian

-- 
            me at the-compiler.org | https://www.qutebrowser.org 
       https://bruhin.software/ | https://github.com/sponsors/The-Compiler/
       GPG: 916E B0C8 FD55 A072 | https://the-compiler.org/pubkey.asc
             I love long mails! | https://email.is-not-s.ms/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20220516/99ecd62e/attachment.sig>


More information about the PyQt mailing list