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


    Can you show the code from that part ?

  • Qt Champions 2016

    In Qt 5.7 it seems happy about it
    alt text

      QVariant test;
      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.