Q_PROPERTY and enum



  • Hello everyone, I have a problem with enum and Q_PROPERTY.
    I created an enum in a class:

    class ClassA 
    {
    Q_OBJECT
       public:
          enum Enum_Test
          {
              eTestA,
              eTestB
          }
        ...
    }
    

    In another class I call this enum in the properties:

    #include "ClassA.h"
    class ClassB
    {
        Q_OBJECT
        Q_ENUMS(ClassA::Enum_Test)
    
        Q_PROPERTY(ClassA::Enum_Test enumTest READ GetEnumTest WRITE SetEnumTest )
    ...
    }
    

    Despite using the Q_ENUMS gives me the following error:
    QMetaProperty::read: Unable to handle unregistered datatype 'ClassA::Enum_Test' for property 'ClassB::enumtest'

    I can not understand where I'm wrong.
    Unfortunately I am obliged to have the Enum in different class from the properties.
    Thanks





  • Thanks, now work fine.
    I use Q_ENUM and I moved it in ClassA

    class ClassA 
    {
    Q_OBJECT
       public:
          enum Enum_Test
          {
              eTestA,
              eTestB
          }
        Q_ENUM(Enum_Test)
        ...
    }
    
    #include "ClassA.h"
    class ClassB
    {
        Q_OBJECT
    
        Q_PROPERTY(ClassA::Enum_Test enumTest READ GetEnumTest WRITE SetEnumTest )
    ...
    }
    

    thanks


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.