With equal enumerations, I was able to access the Q_ENUMS properties and the concrete representation of character enumerations with the following code:
class EnumClass : public QObject
{
Q_OBJECT
public:
enum MyEnumType { TypeA, TypeB };
Q_ENUMS(MyEnumType)
private:
MyEnumType m_type;
};
m_type = TypeA;
...
const QMetaObject &mo = EnumClass::staticMetaObject;
int index = mo.indexOfEnumerator("MyEnumType");
QMetaEnum metaEnum = mo.enumerator(index);
QString enumString = metaEnum.valueToKey(m_type);
If I want to use the C ++ 11 function for strong typed enums, for example
enum class MyEnumType { TypeA, TypeB };
access to metadata no longer works. I believe Qt will no longer recognize it as an enumeration.
Is there any solution for accessing a character enumeration representation of characters when using strong typed enums?
source
share