Error: Qt.createQmlObject(): failed to create object: Non-existent attached object
-
@sierdzio said in Error: Qt.createQmlObject(): failed to create object: Non-existent attached object:
- use
Repeater
in yourGridLayout
to create the items you need
But Repeater supports only one Component as delegate. I want it to fill 2 columns of GridLayout with 2 Text delegates.
Static grid that i am trying to make dynamic:
GridLayout { id: grid columns: 2 Text { text: "first text:"; color: "white"; horizontalAlignment: Text.AlignRight Layout.alignment: Qt.AlignRight } Text { text: "text"; color: "white"} Text { text: "second text:"; color: "white"; horizontalAlignment: Text.AlignRight Layout.alignment: Qt.AlignRight } Text { text: "text text"; color: "white"} Text { text: "the third text:"; color: "white"; horizontalAlignment: Text.AlignRight Layout.alignment: Qt.AlignRight } Text { text: "text text text"; color: "white"} }
Its output:
first text: text second text: text text the third text: text text text
- use
-
@Kyeiv said in Error: Qt.createQmlObject(): failed to create object: Non-existent attached object:
@sierdzio said in Error: Qt.createQmlObject(): failed to create object: Non-existent attached object:
- use
Repeater
in yourGridLayout
to create the items you need
But Repeater supports only one Component as delegate. I want it to fill 2 columns of GridLayout with 2 Text delegates.
Wrap the 2 delegates in a single component and use the
index
property to decide which to use for each cell. - use
-
@jeremy_k yes but still if so, i cannot take advantage of the index property when i use one object, let's say of index 1 to fill 2 Texts
i need something like:
GridLayout { columns: 2 Repeater { model: model.map delegate: Text { text: modelData.label horizontalAlignment: Text.AlignRight Layout.alignment: Qt.AlignRight } Text { text: modelData.value } } }
-
@jeremy_k
what i have: a map of objects which have 2 attributes - label and value.
what i want to achieve: the formatted list of them in form of:first label text: value text second label text: value text the third label text: its value text
so its centered, the " : " in the middle.
-
@Kyeiv said in Error: Qt.createQmlObject(): failed to create object: Non-existent attached object:
GridLayout {
columns: 2
Repeater {
model: model.map
delegate: Text {
text: modelData.label
horizontalAlignment: Text.AlignRight
Layout.alignment: Qt.AlignRight
}
Text {
text: modelData.value
}
}
}Then just put them in one delegate item:
GridLayout { columns: 2 Repeater { model: model.map delegate: Column { Text { text: modelData.label horizontalAlignment: Text.AlignRight Layout.alignment: Qt.AlignRight } Text { text: modelData.value } } } }
-
A ListView appears to be a better match than the more complicated GridLayout and Repeater.
ListView { delegate: Item { width: ListView.view.width height: childrenRect.height Text { anchors.right: parent.horizontalCenter text: modelData.firstPart + ":" } Text { anchors.left: parent.horizontalCenter text: modelData.secondPart } } }