<div dir="ltr">Hello list!<br>I'm a little new here and with qt and pyqt, so i don't know what i'm doing wrong<br><br>I searched the problem and found this link [0] with the same problem (from 2014) and with no solution<br><br>The
problem is that i need to return a list of QObject in a Slot written in
Python to a QML, and when the list arrives to the QML it is a list of
undefined elements. The guess is that the garbage collector delete the
objects from the list before they arrive to the QML.<br><br>In [1] I
make some test with a minimum example. In the main1 example, the Slot
return a list with two elements of a type that inherit from QObject and
have a simple property of a QString type, and in the output the
console.log print the list with two null objects.<br>In the main2
examples I change the return type of the Slot to a QQmlListProperty, and
the result is similar, but now the elements are undefined.<br>In the
main3 example I change the Slot in main2 to a pyqtProperty, and change
the call in the qml to suit that change and the list arrives perfectly.<br>In
the main4 i take the main1 example, but i convert the list in a
instance variable, so the garbage collector will not remove the elements
in the list, and the list arrives perfectly to the QML.<br><br>Is there some good way to solve this? I am doing something wrong?<br><br>Thank to read me!!<br><div><div><div><div><div><div><br>[0] <a href="http://python.6.x6.nabble.com/QML-garbage-collects-the-model-td5064672.html" target="_blank">http://python.6.x6.nabble.com/<wbr>QML-garbage-collects-the-<wbr>model-td5064672.html</a><br>[1] <a href="https://gist.github.com/marcoshipe/81473609c0927bea0a17828de29cc2a9" target="_blank">https://gist.github.com/<wbr>marcoshipe/<wbr>81473609c0927bea0a17828de29cc2<wbr>a9</a></div></div></div></div></div></div><br></div>