1.qml alias使用
qml文件名首字母一定要大写 不然会找不到
Test1.qml
import QtQuick 2.0 Rectangle { property alias buttonText1:textItem.text x: 100;y:30 100;height: 30;color: "#ff0000" Text { id: textItem anchors.centerIn: parent font.pointSize: 10 style: Text.Raised color: "black" } }
调用qml文件名无强制要求
main.qml
import QtQuick 2.2 import QtQuick.Window 2.10 Window { visible: true 640 height: 480 title: qsTr("Hello World") Test1{ buttonText1:"xxxx" } }
在5.10中,每次更新Test1.qml都需要在main.qml中更新下buttonText1的内容要不然显示的不会更新