2013-05-18 119 views
0

Widget.qmlButton.qmlLabel.qml .. 在Widget.qml,有Button元,并在Button.qml,有Label马塔...QML,如何访问子元对象

如何访问在WidgetButton标签...

Widget.qmlLable.qml

+1

什么是“子元对象”?你在Widget.qml中尝试过什么? –

+0

这似乎是XY问题的另一个变体:http://meta.stackexchange.com/questions/66377/what-is-the-xy-problem –

回答

0

只能绑定的Label内部性质标签本身。如果你只是想明确地设置这些属性,你可以把它放在一个JavaScript函数,该组件被创建时称为内:

ClearButton { 
    Component.onCompleted: { label.text = ... } 
} 

或者你可以绑定内ClearButton性能和绑定标签属性的母按钮:

ClearButton { 
    id: button 
    property var text: "登陆" // prefer "property string text" 

    ... 

    Label { 
     text: button.text 
     ... 
    } 
}