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:
Qt Code:
  1. // h
  2. Q_PROPERTY( Operation operation READ operation WRITE setOperation )
  3. Q_ENUMS( Operation );
  4.  
  5. enum Operation
  6. {
  7. A,
  8. B
  9. };
  10.  
  11. // cpp
  12. QDataStrem in( &tcpSocket );
  13. // waiting for all data
  14. QString sTmpTypOperacji;
  15. Operation eTypOperacji;
  16.  
  17. in >> sTmpTypOperacji;
  18.  
  19. const QMetaObject* metaObj = this->metaObject();
  20. int iEnum = metaObj->indexOfEnumerator( "Operation" );
  21. QMetaEnum enumOper = metaObj->enumerator( iEnum );
  22.  
  23. eTypOperacji = (Operation)enumOper.keyToValue( sTmpTypOperacji.toLatin1() );
To copy to clipboard, switch view to plain text mode 
Are there other ways to send enum?