@Pivit I tried your example but for now I have only this in my onCompleted:
console.log("Lights List:", MyManager.lightsList)
console.log("Lights List length:", MyManager.lightsList.length)
and if I debug from the QML into the C++, I see that the correct manager object is called and that the lisghtsList is non-empty:
Filled lights: 5
qml: Lights List: [QVariant(Light, ),QVariant(Light, ),QVariant(Light, ),QVariant(Light, ),QVariant(Light, )]
qml: Lights List length: 5
I think your issue is that you have not properly exposed Light to QML. For a simple struct-type class the easiest thing is to make it a Q_GADGET to expose the properties to QML:
#include <QVariant>
struct Light
{
private:
Q_GADGET
Q_PROPERTY(uint id MEMBER id)
Q_PROPERTY(uint intensity MEMBER intensity)
public:
uint id;
quint16 intensity;
// ... same as your code
};
Q_DECLARE_METATYPE(Light)
I have only exposed the id and intensity members for now, but it is enough to try it out. I added an extra print in the onCompleted:
console.log("Lights List first id:", MyManager.lightsList[0].id)
The output is now:
Filled lights: 5
qml: Lights List: [Light(0, 0),Light(1, 100),Light(2, 200),Light(3, 300),Light(4, 400)]
qml: Lights List length: 5
qml: Lights List first id: 0