Get items after loading a qml file using the Loader QML
-
What is the best way to get an item in a different QML file?
I have something like that:
@
Button {
text: qsTr("text")
onClicked: {
onClicked: circleLoader.source = "circle.qml";
}
}
@And I am getting the attribute width in circle.qml - this file has many rectangles - using this line of code:
@
circleLoader.children[0].width
@Does anyone know a better way of doing this?
Thanks!
-
Hi,
Try with circleLoader.item.width
-
You can access the children object of Item. That is the only way. Your posting already included this.
You can try with only this as you have done it.
@ console.log(pageL.item.children[0].width)
console.log(pageL.item.children[1].width)
@ -
[quote author="Dheerendra" date="1407907351"]You can access the children object of Item. That is the only way. Your posting already included this.
You can try with only this as you have done it.
@ console.log(pageL.item.children[0].width)
console.log(pageL.item.children[1].width)
@[/quote]OK, thank you very much.