Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
QVariant to std::vector
PJB0515 last edited by
Is it possible to convert from a QVariant to a std::vector? Basically I wrapped a MyStruct up in a QVariant, this went all good, but MyStruct holds a vector of MyStruct2s. So in my QTableModel, i'm trying to access that vector via the overridden data() function, but I am not sure how to get it back into the vector state.
Zlatomir last edited by
The [url=http://doc.trolltech.com/4.6/qvariant.html#value]value()[/url] should do the trick, see canConvert() too.
ogoffart last edited by
QVariant can contains std::vector, you just need to do somewhere
But you may want to convert to QVector before with QVector::from/toStdVector(). This really depends of your use case.