[PyQt] Getting parent class for an enum
    Phil Thompson 
    phil at riverbankcomputing.com
       
    Wed Jun  6 10:36:46 BST 2018
    
    
  
On 17 May 2018, at 9:23 am, Phil Thompson <phil at riverbankcomputing.com> wrote:
> 
> On 16 May 2018, at 1:57 pm, Denis Rouzaud <denis.rouzaud at gmail.com> wrote:
>> 
>> Hi,
>> 
>> In the case of an enum (with Q_ENUM macro), it would be interesting to have a way to get the parent class to be able to get the meta enum from the enum value (enumValue):
>> 
>> base = type(enumValue).parentClass()
>> idx = base.staticMetaObject.indexOfEnumerator(type(enumValue).__name__)
>> metaenum = base.staticMetaObject.enumerator(idx)
>> 
>> Would it be possible to add this capability to sip.enumType ?
>> Either to return the parent class or directly the metaEnum?
> 
> Are you asking for an implementation of QMetaEnum.fromType()?
> 
> For example...
> 
>    metaenum = QMetaEnum.fromType(type(Qt.Key_F1))
...on second thoughts, that's not what you are asking for.
For Qt enums you should be able to do that using __module__ and __qualname__ (now that qualname is fixed) to find the class and its meta-object.
Phil
    
    
More information about the PyQt
mailing list