3

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);
};
  1. This is a follow up of: Qt: No metadata by meta.enumeratorCount() for enum in Q_OBJECT, why?
  2. 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 original enum is not(!) an Q_OBJECT.
Community
  • 1
  • 1
Horst Walter
  • 13,663
  • 32
  • 126
  • 228

0 Answers0