I have a QVariantList containing objects of different classes. I need to modify a member variable of one object held in the list. My code runs, but the object is not changing (looks like a copy of the object is being changed). Here is sample code similar to what I'm doing:
QVariantList l;
QVariant v = l.at(0);
MyClass c;
if (v.canConvert<MyClass >()) c = v.value<MyClass >();
c.myfield(10);
// l.at(0) has not changed
I also tried:
qvariant_cast<MyClass>(v).myfield(10)
but no difference. I want to change myfield of the object, not a copy of the object. How do I modify the 'myfield' field of the object held in the QVariant v.