I have MyType
registered as qmlRegisterSingletonType<MyType>("org.examples", 1, 0, "MyType")
which has QmlListProperty<MyListElement>
- myList
.
What syntax i should use at QML side to assign something to MyType.myList
?
Seems like that is incorrect:
Component.onCompleted: {
MyType.myList = [
MyListElement {
}
]
}
You have to create the MyListElement object using javascript and then add it to the list with push since QmlListProperty is translated to a list in QML.
In this case with Qt.createQmlObject()
, so assuming MyListElement was created with:
qmlRegisterType<MyListElement>("org.examples", 1, 0, "MyListElement");
So the solution is:
Component.onCompleted: {
var o = Qt.createQmlObject('import org.examples 1.0; MyListElement {}', this)
// o.foo_property = foo_value;
MyType.myList.push(o);
}