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.
QVariant to std::vector
QVariant can contains std::vector, you just need to do somewhere
Then you can use QVariant::fromValue<std::vector>(v); and variant.value<std::vector>();
But you may want to convert to QVector before with QVector::from/toStdVector(). This really depends of your use case.Reputation: 15 | Posts: 21