5
プロパティの色と変更値テキスト要素をqtquickプロジェクトに追加しますか?
my.qmlファイルの内容。QtQuickでプロパティを見つけて値を変更する方法
Rectangle {
width: 300
height: 200
Text {
x: 12
y: 34
color:red
}
}
プロパティの色と変更値テキスト要素をqtquickプロジェクトに追加しますか?
my.qmlファイルの内容。QtQuickでプロパティを見つけて値を変更する方法
Rectangle {
width: 300
height: 200
Text {
x: 12
y: 34
color:red
}
}
あなたは以下のようにObjectNameプロパティを設定する必要があります。
Rectangle {
width: 300
height: 200
Text {
objectName: "text1"
x: 12
y: 34
color: "red"
}
}
今あなたが見つけると要素とプロパティにアクセスすることができます。
たとえば、テキスト要素で色を見つけて緑色に変更します。
view = QDeclarativeView(QUrl('widget.qml'),parent = object)
property = QDeclarativeProperty(view.rootObject().findChild(QDeclarativeItem, name="text1"),"color")
property.write("green")