2017-06-20 13:52 GMT+02:00 Ola Røer Thorsen <o...@silentwings.no>:
> function doStuff() { > var o = theGadget; > console.log("o.name"); // prints "Name" > o.name = "Some other name"; // No error, but nothing really happens > either > console.log("o.name"); // Still prints "Name" instead of "Some other > name" > backend.setNewGadget(o); > } > > Turns out that the problem is that "o" in this case is not really my MyGadget type, but rather a QVariant (?) containing the MyGadget type because it was exposed to QML via a C++ list model (the model data() function returns the gadget wrapped in QVariant). If I make a hack addition to my class like Q_INVOKABLE MyGadget getMyself() const { return *this; } then call var o = theGadget.getMyself(); o.name = ... it actually works. If any of you have some better way to do this I'd be happy to learn about it. The QVariant::value function is not callable in qml. Could the behavior with silently ignoring assigning property values when wrapped in QVariant be considered a bug? If so I'll make a bug report. Best regards, Ola
_______________________________________________ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest