I'm extending QML with my own widget from c++, with DefaultProperty and QQmlListProperty, like here.
So that I can write
Parent {
Child { prop: "ch1" }
Child { prop: "ch2" }
Child { prop: "ch3" }
}
The Child objects are appending to a member property of type QQmlListProperty.
But when I want to use a Repeater like this:
Parent {
Repeater {
model: ["ch1","ch2","ch3"]
delegate: Child {
prop: modelData
}
}
}
Then the runtime gives me an error: Cannot assign object to list property "childObjects"
How can I set the list property of my Parent object which a Repeater?
EDIT: I've found out, that the Repeater inherits Item and can repeat only Items. But my Child object inherits QObject. So I must create a Repeater for QObjects. But that isn't the problem. How can the Item object have a manually written child items, and also a Repeater child which gives him many children?
Repeaterused for visual items only. But you can createChildobjects withQt.createComponent()in loop. Or implement such functionality asRepeaterwith C++ extension. - folibisRepeaterclass has so many private members, and uses classes that are not publicly available ... - microo8Qt.createComponent()in loop. All you need, as I understand is creating a component and assigning it toParent. - folibis