Let's assume I have an existing enum X { A, B }
and want to use it with Qt metadata such as QMetaObject
/ QMetaEnum
.
QMetaObject meta = FsxSimConnectQtfier::staticMetaObject;
for (int i=0; i < meta.enumeratorCount(); ++i) {
QMetaEnum m = meta.enumerator(i);
}
If I define my enum
within a Q_OBJECT
class, all is fine, i.e. I can retrieve MyEnum
by the metadata system. But how can I make X
available for the metadata system?
class FsxSimConnectQtfier : public QObject
{
Q_OBJECT
Q_ENUMS(MyEnum)
Q_ENUMS(X) // not working
public:
explicit FsxSimConnectQtfier(QObject *parent = 0);
enum MyEnum { G1, G2 };
// how can I make enum X available for the metadata system
// I have tried typedef, but did not work
static const QString simConnectExceptionToString(const unsigned int id);
};
- This is a follow up of: Qt: No metadata by meta.enumeratorCount() for enum in Q_OBJECT, why?
- Motivation: The real
enum X
contains many exception codes, and I want to use the metadata system to fetch the original descriptive text, pretty much as here. The originalenum
is not(!) anQ_OBJECT
.