简单展示 Loader 使用并修改对应控件内容的方式(持续更新)
Component {
id: buttonDirection
ToolButton {
display: AbstractButton.IconOnly
icon.source: ""
background: Rectangle {
color: "transparent" //透明
}
topPadding: down ? 10 : 8 //营造下陷的点击效果
}
}
Loader {
id: leftLoader
sourceComponent: buttonDirection
anchors.verticalCenter: parent.verticalCenter
anchors.left: parent.left
onLoaded: { //在这里编辑控件的相关属性参数
item.icon.source = "qrc:/image/xxx.png"
}
}
//item 就是只想 buttonDirection 对象
//如果控件太大需要使用 asynchronous 具体用法查看手册
//setSource 可以动态添加对象并同时修改属性值 具体查看手册