<div dir="ltr">Hello,<div>I'd be very grateful if someone could confirm whether the solution to the following two scenarios is valid:</div><div><br><div>I'd like to be able to call a pyqtSlot from QML, have the slot instantiate and return a QObject, and have the QML take over the ownership of the object, without having to keep an explicit reference to the object on the python side. Without explicitly using sip.transferto (as suggested in this stackoverflow answer <a href="http://stackoverflow.com/a/24696295/858766">http://stackoverflow.com/a/24696295/858766</a> - the question was posted by me, please go through it if you have time), the object is garbage collected before it even reaches the QML side.</div>
</div><div>Is using sip.transferto the correct approach here?</div><div><br></div><div>Additionally, there's a similar problem when the situation is reversed. If I expose a class Dummy via qmlRegisterType and then instantiate it in QML using Dummy {} (e.g. as a ListView delegate), a segfault will occur as soon as the delegate gets out of ListView visible area and gets destroyed. In this case I can add sip.transferto in the constructor but it doesn't seem right, and it also causes the process to not quit after the event loop exits. Should I transfer the ownership back? </div>
<div>Is sip.transferto even something a PyQt user should be using and be aware of?</div><div><br></div><div>In both cases I don't see the destructors being triggered (by the fact that there's no print output from the overridden __del__ and connected destroyed signal handler), which contributes to my concern about the approach.</div>
<div><br></div><div><br></div></div>