可以插图中的QML多个窗口,只是以同样的方式,传达你的任何其他两者之间的沟通Items
通过引用它们或通过id
s或将它们分配给您稍后用于引用它们的属性。 考点:
import QtQuick 2.7
import QtQuick.Controls 2.0
import QtQuick.Layouts 1.0
Item {
ApplicationWindow
{
id: appWindow
width: 500
height: 800
visible: true
ListModel {
id: lm
Component.onCompleted: {
for (var i = 0; i < 42; i++) append({ message: 'Hellow World ' + i })
}
}
ListView {
id: lv
width: 300
height: 800
model: lm
delegate: Button {
text: model.message
onClicked: secondWindow.text = text
}
}
}
ApplicationWindow
{
id: secondWindow
width: 500
height: 800
x: appWindow.x + 500
y: appWindow.y
visible: true
property alias text: label.text
Text {
id: label
anchors.centerIn: parent
}
}
}