I need send an enum through network. I have idea how to do this, but I want to know yours solutions for this. Maybye there is better way than my.
My idea:
// h
Q_PROPERTY( Operation operation READ operation WRITE setOperation )
Q_ENUMS( Operation );
enum Operation
{
A,
B
};
// cpp
QDataStrem in( &tcpSocket );
// waiting for all data
Operation eTypOperacji;
in >> sTmpTypOperacji;
int iEnum = metaObj->indexOfEnumerator( "Operation" );
QMetaEnum enumOper
= metaObj
->enumerator
( iEnum
);
eTypOperacji = (Operation)enumOper.keyToValue( sTmpTypOperacji.toLatin1() );
// h
Q_PROPERTY( Operation operation READ operation WRITE setOperation )
Q_ENUMS( Operation );
enum Operation
{
A,
B
};
// cpp
QDataStrem in( &tcpSocket );
// waiting for all data
QString sTmpTypOperacji;
Operation eTypOperacji;
in >> sTmpTypOperacji;
const QMetaObject* metaObj = this->metaObject();
int iEnum = metaObj->indexOfEnumerator( "Operation" );
QMetaEnum enumOper = metaObj->enumerator( iEnum );
eTypOperacji = (Operation)enumOper.keyToValue( sTmpTypOperacji.toLatin1() );
To copy to clipboard, switch view to plain text mode
Are there other ways to send enum?
Bookmarks