Hi everyone,
I am trying to get the string value of enum.
My classa.h:
Qt Code:
  1. class classA : public QObject
  2. {
  3. Q_OBJECT
  4. Q_ENUMS(errType)
  5. public:
  6. enum errType{SUCCESS,ERROR};
  7. classA();
  8.  
  9. };
To copy to clipboard, switch view to plain text mode 

main.cpp:
Qt Code:
  1. int index = classA::staticMetaObject.indexOfEnumerator("errType");
  2. qDebug()<<index;
  3.  
  4. const QMetaObject & mo = classA::staticMetaObject;
  5. qDebug() << "Available enums in" << mo.className() << ":" << mo.enumeratorCount();
To copy to clipboard, switch view to plain text mode 

If i will compile with Q_OBJECT then undefined reference to classA::staticMetaObject and undefined reference to vtable for classA built error will come.
If i will compile without Q_OBJECT then compilation will be fine.But index will be -1 and enumetator count will be 0.

Please tell how i will register the enum and get the string value of enum.

Thanks.