У меня есть один файл index.qml, который состоит из двух прямоугольников, которые заполняют экран в пропорциях ~ 3: 1.В обоих из них я загружаю один и тот же файл window.qml.Что мне нужно, это назначить разные значения для свойства ORIENT, чтобы window.qml вел себя немного иначе.
Посмотрите на пример ниже.Этот ORINET просто показывает, чего я хотел бы достичь ...
index.qml
Rectangle {
id: rootA
anchors.left: parent.left
anchors.top: parent.top
width: parent.width * 0.65
// set some property or function so it will be seen in loaded window.qml
// sth like:
property ORINET: "horizontal"
Loader {
anchors.left: parent.left; anchors.top: parent.top;
anchors.right: parent.right; anchors.bottom: parent.bottom
source: "window.qml"
}
}
Rectangle {
id: rootB
anchors.right: parent.right
anchors.top: parent.top
width: parent.width * 0.35
// set some property or function so it will be seen in loaded window.qml
// sth like:
property ORINET: "vertical"
Loader {
anchors.left: parent.left; anchors.top: parent.top;
anchors.right: parent.right; anchors.bottom: parent.bottom
source: "window.qml"
}
}
window.qml
Rectangle {
id: windowBox
state [
...
]
...
Component.onCompleted: {
windowBox.state = ORINET
}
}