QVariant appears to accept QList<QVariant>
and not QVector<QVariant>
nor QLinkedList<QVariant>
. Is it simply because it sees QList
, QVector
and QLinkedList
as fundamentally similar (in an abstract sense) data structures?
I'm adding and std::vector
to a QVariant
. If using only the Qt API and not a manual conversion, this requires two conversions:
std::vector
to QVector
QVector
to QList
PS: I'm aware that I can add std::vector
to QVariant
directly with this but I believe in that case it won't know that it's a vector of objects.
you may store everything in QVariant, after calling to qRegisterMetaType function.
so if you call qRegisterMetaType<std::vector<SomeObject> >("std::vector<SomeObject>");
QVariant WOULD store std::vector.
reading such values from it performing function T QVariant::value () const
, for writing use function void QVariant::setValue ( const T & value )
PS: I'm aware that I can add std::vector to QVariant directly with this but I believe in that case it won't know that it's a vector of objects.
When you registering type to QVariant, it calls it's default constructor,copy constructor and destructor while manipulating items of that type. So there is no harm to use it with classes and objects.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With