如果qml或者c++文件1.包含有qmldir文件,2.并且该qmldir文件带有module metadata,3.并且该qmldir文件被安装到qml import path,则在文件系统中的任何一个qml文件能够import url语句将该model引入,从而使用module里面的对象类型和javascript资源
https://doc.qt.io/qt-5/qtqml-modules-identifiedmodules.html#semantics-of-identified-modules
qml 如果有根据条件更改控件的样式,一般可以使用if语句进行控制,还可以使用State进行控制例如:
import QtQuick 2.0
Rectangle {
id: myRect
width: 100; height: 100
color: "black"
MouseArea {
id: mouseArea
anchors.fill: parent
onClicked: myRect.state == 'clicked' ? myRect.state = "" : myRect.state = 'clicked';
}
states: [
State {
name: "clicked"
PropertyChanges { target: myRect; color: "red" }
}
]
}