<div dir="ltr">I've had similar problem and did not find a solution at the time.<div><br></div><div>While getMyself() feels hackish, it does indeed work. Thanks a lot for sharing! :-)<br><div class="gmail_extra"><br><div class="gmail_quote">On 20 June 2017 at 15:06, Ola Røer Thorsen <span dir="ltr"><<a href="mailto:ola@silentwings.no" target="_blank">ola@silentwings.no</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote"><span class="">2017-06-20 13:52 GMT+02:00 Ola Røer Thorsen <span dir="ltr"><<a href="mailto:ola@silentwings.no" target="_blank">ola@silentwings.no</a>></span>:<br><div> </div></span><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><span class=""><div>function doStuff() {</div><div>   var o = theGadget;</div><div>   console.log("<a href="http://o.name" target="_blank">o.name</a>"); // prints "Name"</div></span><div>   <a href="http://o.name" target="_blank">o.name</a> = "Some other name"; // No error, but nothing really happens either</div><span class=""><div>   console.log("<a href="http://o.name" target="_blank">o.name</a>"); // Still prints "Name" instead of "Some other name"</div><div>   backend.setNewGadget(o);</div><div>}</div><div><br></div></span></div></blockquote><div><br></div><div>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).</div><div><br></div><div>If I make a hack addition to my class like</div><div>Q_INVOKABLE MyGadget getMyself() const { return *this; }</div><div><br></div><div>then call</div><div>var o = theGadget.getMyself();</div><div><a href="http://o.name" target="_blank">o.name</a> = ...</div><div><br></div><div>it actually works.</div><div><br></div><div>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. </div><div><br></div><div>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.</div><div><br></div><div>Best regards,</div><div>Ola</div><div><br></div><div><br></div><div><br></div></div></div></div>
<br>______________________________<wbr>_________________<br>
Interest mailing list<br>
<a href="mailto:Interest@qt-project.org">Interest@qt-project.org</a><br>
<a href="http://lists.qt-project.org/mailman/listinfo/interest" rel="noreferrer" target="_blank">http://lists.qt-project.org/<wbr>mailman/listinfo/interest</a><br>
<br></blockquote></div><br></div></div></div>