Reputation: 772
how to find property color and change value for Text element in my qtquick project?
content on my.qml file.
Rectangle {
width: 300
height: 200
Text {
x: 12
y: 34
color:red
}
}
Upvotes: 5
Views: 1311
Reputation: 158
you need to set objectName property like below:
Rectangle {
width: 300
height: 200
Text {
objectName: "text1"
x: 12
y: 34
color: "red"
}
}
now you can find and access to element and property.
for example, i find color in Text element and change to green:
view = QDeclarativeView(QUrl('widget.qml'),parent = object)
property = QDeclarativeProperty(view.rootObject().findChild(QDeclarativeItem, name="text1"),"color")
property.write("green")
Upvotes: 6