[PyQt] QMetaEnum from PyQt?

Florian Bruhin me at the-compiler.org
Thu Nov 23 18:53:10 GMT 2017


On Thu, Nov 23, 2017 at 04:39:55PM +0000, J Barchan wrote:
> I would like to convert an enum to its string (in this case, for a
> QProcess.ProcessError).  C++ code would be as per e.g.
> https://stackoverflow.com/a/34282031/489865, or possibly one of the other
> solutions there or elsewhere.  Note that this is only for Qt5, but I do
> have to support 5.5 onward, which rules out one of the answers there.
> 
> Is this possible from PyQt/Python, and if so would you be kind enough to
> show Python/PyQt code, as it's a bit hard to figure with those C++ type
> statements etc.?

Here's what I use to do that:
https://github.com/qutebrowser/qutebrowser/blob/v1.0.3/qutebrowser/utils/debug.py#L95-L131
https://github.com/qutebrowser/qutebrowser/blob/v1.0.3/tests/unit/utils/test_debug.py#L125-L154

Florian

-- 
https://www.qutebrowser.org  | me at the-compiler.org (Mail/XMPP)
   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/20171123/7c8c461b/attachment.sig>


More information about the PyQt mailing list