Unfortunately, our software uses certain data-holding object called ProcessContext
which holds the data in string indexed map (QMap<QString, QVariant>
. This patter will not be changed right now but I need to stuff more complex data than string and numbers to it.
My specific data is a QList<MyClass>
which contains instances of my own class. Surprisingly such list really can be converted to and from QVariant
. I asked question about that: Can I conveniently converty QVariant back to QList<MyType>?
The procedure looks like:
QList<MyType> list_original;
QVariant variant = QVariant::fromValue(list_original);
// And later on...
if( variant.canConvert<QList<MyType>>() ) {
QList<MyType> list_new = variant.value<QList<MyType>>();
...
}
Now the issue here is, that any changes done to list_new
will not affect the data in the QVariant variant
.
My question here therefore is how to ensure that the QVariant
returns refference on the data it covers, rather than copy.