做UI界面开发时,在一个QML文件中使用Component自定义一个组件。使用Loader加载多个,怎样去修改自定义组件中的属性。
尝试过一些方法,直接在Component中 property 定义属性,会报错不可以新增变量属性
Rectangle{
Loader{
sourceComponent: test
onLoaded: {
rec_text.text = "123
}
}
Component{
id:test
Rectangle{
id:rec
Text {
id:rec_text
text: qsTr("abcd")
}
}
运行结果是没有出现更改
我通过property定义属性值,放在哪里都无法更改