The fact that the QObject is non copiable, is one of the reason it need a pointer (which can be copied). As for the ownership, you can check with the qqmlengine: https://doc.qt.io/qt-5/qqmlengine.html#objectOwnership
You can change the ownership too with setOwnership(). I for one exposed the methods to Qml so each side can check/set the qobject ownership based on the needs. This is very helpful to debug. You can use QPointer to have a pointer that will return to null if the qobject get deleted. Hope this help. [36E56279] une compagnie [cid:image002.jpg@01D4D011.EF589B50] RAPPROCHEZ LA DISTANCE Jérôme Godbout Développeur Logiciel Sénior / Senior Software Developer p: +1 (418) 800-1073 ext.:109 amotus.ca<http://www.amotus-solutions.com/> statum-iot.com<http://statum-iot.com/> [cid:image003.png@01D4D011.EF589B50]<https://www.facebook.com/LesSolutionsAmotus/> [cid:image004.png@01D4D011.EF589B50] <https://www.linkedin.com/company/amotus-solutions/> [cid:image005.png@01D4D011.EF589B50] <https://twitter.com/AmotusSolutions> [cid:image006.jpg@01D4D011.EF589B50] <https://www.youtube.com/channel/UCoYpQgsmj1iJZyDjTQ3x8Ig> From: Interest <interest-boun...@qt-project.org> On Behalf Of Sylvain Pointeau Sent: March 1, 2019 6:44 AM To: Qt Project <interest@qt-project.org> Subject: [Interest] using a custom class as parameter of signal/slot, used in QML Dear all, I understood how to use a struct / simple class as a parameter of a signal / slot, and it works well by value. However as soon as we have to declare the type for QML, it is not good anymore. It seems that it must be derived from QObject and passed by pointer. Do I understand well that the QML world does only accept pointers on QObject? However I don't understand, who owns the pointer of the custom class (derived from QObject) and who actually deletes it? (I tried a sharepointer but QML does not know how to handle it) Do you have any idea? Best regards, Sylvain
_______________________________________________ Interest mailing list Interest@qt-project.org https://lists.qt-project.org/listinfo/interest