[PyQt] Access QObject's staticQtMetaObject private member

Florian Bruhin me at the-compiler.org
Sun Nov 15 08:48:05 GMT 2015


* Kernc <kerncece at gmail.com> [2015-11-15 00:11:20 +0100]:
> With it, one can then extract "meta" information of the Qt namespace,
> namely the string names of various enum values [1].
> 
> Is there, or would there be a use for, anything similar in PyQt?
> 
> Given:
> 
> >>> from PyQt5.QtCore import Qt
> >>> buttons = Qt.LeftButton | Qt.RightButton
> 
> is it at all possible to obtain str 'LeftButton' as one of the set
> flags from the value of `buttons` without depending on Qt C++ sources
> and without creating an own mapping dict of all possible values (by
> name) for QtCore.Qt.MouseButton enum class (and likewise for all other
> possible enum classes of interest)?
> 
> Thanks for any suggestions!

FWIW, I have some code to do this which also works for values without
a staticMetaObject:

https://github.com/The-Compiler/qutebrowser/blob/master/qutebrowser/utils/debug.py#L91-L167
https://github.com/The-Compiler/qutebrowser/blob/master/tests/unit/utils/test_debug.py#L125-L185

Florian

-- 
http://www.the-compiler.org | me at the-compiler.org (Mail/XMPP)
   GPG: 916E B0C8 FD55 A072 | http://the-compiler.org/pubkey.asc
         I love long mails! | http://email.is-not-s.ms/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20151115/a6dd86ee/attachment.sig>


More information about the PyQt mailing list