Hello,
I am trying to get text representation of SocketState enum.

In the header of my class i registered the enum:

Qt Code:
  1. class QSound;
  2. class SoundNode : public QObject
  3. {
  4. Q_OBJECT
  5. public:
  6. Q_ENUMS(QAbstractSocket::SocketState);
To copy to clipboard, switch view to plain text mode 

In the source:

Qt Code:
  1. QMetaObject metaObject ;
  2. metaObject= QAbstractSocket::staticMetaObject;
  3. QMetaEnum metaEnum = metaObject.enumerator(metaObject.indexOfEnumerator("SocketState" ) );
  4. QString test(metaEnum.valueToKey(QAbstractSocket::ConnectionRefusedError));
  5. qDebug()<<test;
To copy to clipboard, switch view to plain text mode 

Here qDebug returns an empty string instead of "ConnectionRefusedError". What is going wrong here, any idea?

Thanks in advance..