[PyQt] How to get Qt enum class
me at the-compiler.org
Fri Aug 29 08:34:07 BST 2014
* Phil Thompson <phil at riverbankcomputing.com> [2014-08-14 14:50:18 +0100]:
> On 07/08/2014 7:27 am, Florian Bruhin wrote:
> >I wrote a function to get the key name in a Qt enum from a value,
> >intended for debugging mainly. This is how it looks right now:
> > <snip>
> >Now ideally I'd just pass in the value and nothing else, however I
> >didn't find a way to get the Qt class where the enum is in, e.g. get
> >QFont when I have QFont.Sunken:
> ><class 'PyQt5.QtGui.Weight'>
> ><class 'sip.enumtype'>
> >Is there a way I could do this, or do I have to pass this explicitely?
> Currently QFont.Weight.__qualname__ returns 'Weight'. Maybe it should return
> 'QFont.Weight' instead, the argument being that an enum is a type and should
> be treated like a nested class.
> Would that solve your problem?
Hmm. It'd certainly make it a bit easier.
However that sparks an idea: Would it be possible for enum *members*
to have a __name__ and a __qualname__? Basically like this:
'QFont.Bold' # or maybe 'QFont.Weight.Bold'?
That'd basically do what my qenum_key function does, but without all
http://www.the-compiler.org | me at the-compiler.org (Mail/XMPP)
GPG 0xFD55A072 | 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: not available
Size: 819 bytes
Desc: not available
More information about the PyQt