Unsolved StackView pop
-
Hi,
I develop a android app using Qt. I have a StackView in main.qml. I use this StackView push other page. I have page A, B, C, D...
Now, in main StackView push A page, in A push to B, in B push to C... ( A->B->C ) When in page C, I want to pop page A not B.
How to I do this?main.qml
{ StackView { id: stackView anchors.fill: parent } Button { onClicked: stackView.push("qrc:/A.qml") } }
A.qml { Button { onClicked: stackView.push("qrc:/B.qml") } }
B.qml { Button { onClicked: stackView.push("qrc:/C.qml") } }
C.qml { Button { onClicked: // I want to pop to page A not B } }
Thanks!!!
-
See the docs: https://doc.qt.io/qt-5/qml-qtquick-controls2-stackview.html#currentItem-prop
If the item argument is specified, all items down to (but not including) item will be popped. If item is null, all items down to (but not including) the first item is popped. If not specified, only the current item is popped.
To get back to A, you can call:
stackView.pop(null) // or stackView.pop("qrc:/A.qml")