0
有Widget.qml
,Button.qml
,Label.qml
.. 在Widget.qml
,有Button
元,並在Button.qml
,有Label
馬塔...QML,如何訪問子元對象
如何訪問在Widget
Button
標籤...
有Widget.qml
,Button.qml
,Label.qml
.. 在Widget.qml
,有Button
元,並在Button.qml
,有Label
馬塔...QML,如何訪問子元對象
如何訪問在Widget
Button
標籤...
只能綁定的Label
內部性質標籤本身。如果你只是想明確地設置這些屬性,你可以把它放在一個JavaScript函數,該組件被創建時稱爲內:
ClearButton {
Component.onCompleted: { label.text = ... }
}
或者你可以綁定內ClearButton
性能和綁定標籤屬性的母按鈕:
ClearButton {
id: button
property var text: "登陸" // prefer "property string text"
...
Label {
text: button.text
...
}
}
什麼是「子元對象」?你在Widget.qml中嘗試過什麼? –
這似乎是XY問題的另一個變體:http://meta.stackexchange.com/questions/66377/what-is-the-xy-problem –