好的,它可以简单到将四个视图放在一起,隐藏除活动视图之外的所有视图。然后创建一个按钮组,以确定哪些视图处于活动状态:
ApplicationWindow {
id: window
visible: true
width: 640
height: 480
ButtonGroup { buttons: buts.children }
Column {
Row {
id: buts
Button {
id: v1
checkable: true
checked: true
text: "red view"
}
Button {
id: v2
checkable: true
text: "green view"
}
Button {
id: v3
checkable: true
text: "blue view"
}
}
Item {
width: 300
height: 300
Rectangle {
anchors.fill: parent
color: "red"
visible: v1.checked
}
Rectangle {
anchors.fill: parent
color: "green"
visible: v2.checked
}
Rectangle {
anchors.fill: parent
color: "blue"
visible: v3.checked
}
}
}
}