qml StackView
59浏览 · 2024-02-01 11:03:04
以下是两个关于QML StackView的示例:
1. 使用replace()方法进行页面切换
```qml
import QtQuick
import QtQuick.Controls
Applic[ati](https://geek.csdn.net/educolumn/150d7073277950db5f09620704e791cf?spm=1055.2569.3001.10083)on[window](https://geek.csdn.net/educolumn/03e5a5a554174a38fdfeb8376bd685e2?spm=1055.2569.3001.10083) {
title: qsTr("Hello World")
width: 640
height: 480
visible: true
StackView {
id: stackView
anchors.fill: parent
initialItem: Component {
id: [page](https://geek.csdn.net/educolumn/1c66455c37fe0c4b32e4414c4c6aeead?spm=1055.2569.3001.10083)
[page](https://geek.csdn.net/educolumn/1c66455c37fe0c4b32e4414c4c6aeead?spm=1055.2569.3001.10083) {
Row {
spacing: 20
anchors.centerIn: parent
Button {
text: "<"
onClicked: stackView.replace([page](https://geek.csdn.net/educolumn/1c66455c37fe0c4b32e4414c4c6aeead?spm=1055.2569.3001.10083), StackView.PopTransition)
Button {
text: ">"
onClicked: stackView.replace(page, StackView.PushTransition)