With plain enums I was able to access Q_ENUMS properties and specific, the character represenation of enums, with following code:
// in .h
class EnumClass : public QObject
{
Q_OBJECT
public:
enum MyEnumType { TypeA, TypeB };
Q_ENUMS(MyEnumType)
private:
MyEnumType m_type;
};
// in .cpp
m_type = TypeA;
...
const QMetaObject &mo = EnumClass::staticMetaObject;
int index = mo.indexOfEnumerator("MyEnumType");
QMetaEnum metaEnum = mo.enumerator(index);
QString enumString = metaEnum.valueToKey(m_type); // contains "TypeA"
If I want to use the c++11 feature for strong typed enums like
enum class MyEnumType { TypeA, TypeB };
accessing the meta information does not work anymore. I guess, that Qt does not recognize it as an enum anymore.
Is there any solution to access the character represenation of an enum while using strong typed enums?