PyQt6 and invalid enums: QKeySequence/QKeyCombination
Florian Bruhin
me at the-compiler.org
Thu Apr 28 18:18:21 BST 2022
Hey,
I wanted to report another case where I see invalid enum ValueErrors
from PyQt6 without doing anything wrong. Not sure if this changes
anything about the big picture, but maybe it does, given that the
underlying issue is a bit different:
>>> qkeycombination = QKeySequence("\x80")[0]
>>> qkeycombination.key()
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python3.10/enum.py", line 385, in __call__
return cls.__new__(cls, value)
File "/usr/lib/python3.10/enum.py", line 710, in __new__
raise ve_exc
ValueError: 128 is not a valid Qt.Key
I think Qt.Key is special in that regard because unicode characters
(at least those not represented in the enum) just end up as a
pseudo-member of that enum:
https://github.com/qt/qtbase/blob/v6.3.0/src/corelib/global/qnamespace.h#L677-L682
This seems reflected in some places of the Qt API (I think that's why
e.g. QKeyEvent.key() returns an int, not a Qt.Key), but evidently not in
others (QKeyCombination.key() in this case).
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/20220428/16ecc210/attachment.sig>
More information about the PyQt
mailing list