Hello,
I am trying to get text representation of SocketState enum.
In the header of my class i registered the enum:
{
Q_OBJECT
public:
class QSound;
class SoundNode : public QObject
{
Q_OBJECT
public:
Q_ENUMS(QAbstractSocket::SocketState);
To copy to clipboard, switch view to plain text mode
In the source:
QMetaEnum metaEnum
= metaObject.
enumerator(metaObject.
indexOfEnumerator("SocketState" ) );
qDebug()<<test;
QMetaObject metaObject ;
metaObject= QAbstractSocket::staticMetaObject;
QMetaEnum metaEnum = metaObject.enumerator(metaObject.indexOfEnumerator("SocketState" ) );
QString test(metaEnum.valueToKey(QAbstractSocket::ConnectionRefusedError));
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..
Bookmarks