you need to set the objectName property as shown below:
Rectangle {
width: 300
height: 200
Text {
objectName: "text1"
x: 12
y: 34
color: "red"
}
}
Now you can find and access elements and properties.
for example, I find the color in a text element and change it to green:
view = QDeclarativeView(QUrl('widget.qml'),parent = object)
property = QDeclarativeProperty(view.rootObject().findChild(QDeclarativeItem, name="text1"),"color")
property.write("green")
source
share