QVariant to/from QFlag



  • I'm unit testing a function for a table model, where it emits 'headerDataChanged'. One of the fields in this signal is a 'Qt::Orientation' flag. When a QSignalSpy picks it up, the QVariant for the orientation field is an invalid one. I can't cast back to Qt::Orientation. Do I have to locally declare orientation as a metatype? It seems odd it wouldn't just treat it as an int or something.


  • Lifetime Qt Champion

    Hi,

    Can you show the code from that part ?


  • Qt Champions 2016

    Hi
    In Qt 5.7 it seems happy about it
    alt text

      QVariant test;
      test.setValue(Qt::Orientation::Vertical);
      Qt::Orientation back = test.value<Qt::Orientation >();
      qDebug() << "i see " << back;
    
    

Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.