How to change the page in QML?
-
wrote on 17 Mar 2021, 20:29 last edited by
Hi,
I have a lot of QML pages and the page has to be changed every time I press the button. Pages can be moved forward or back to the previous page. I used StackView , but this do not correct. When push button , new page overlap on base page and just work for one page. what is your suggestion?StackView {
id: stackView
initialItem: "HomeForm.ui.qml"
anchors.fill: parent
}
Drawer {
id: drawer
}
ItemDelegate {
x: 0
y: 2
// text: qsTr("Page 1")
width: parent.width
Button {
id: button
x: 265
y: 351
text: qsTr("Button")// anchors.fill: parent onClicked: { stackView.push("Page1Form.ui.qml") drawer.close() } } } }
-
Hi,
I have a lot of QML pages and the page has to be changed every time I press the button. Pages can be moved forward or back to the previous page. I used StackView , but this do not correct. When push button , new page overlap on base page and just work for one page. what is your suggestion?StackView {
id: stackView
initialItem: "HomeForm.ui.qml"
anchors.fill: parent
}
Drawer {
id: drawer
}
ItemDelegate {
x: 0
y: 2
// text: qsTr("Page 1")
width: parent.width
Button {
id: button
x: 265
y: 351
text: qsTr("Button")// anchors.fill: parent onClicked: { stackView.push("Page1Form.ui.qml") drawer.close() } } } }
wrote on 18 Mar 2021, 00:13 last edited byhi
@Saeed_Nowroozi said in How to change the page in QML?:
but this do not correct. When push button , new page overlap on base page
that is the normal behavior of the stackView, you can push pages to it and it will stack them. You can also decide to remove (pop()) one page before you push a new one. See here everithing you can do https://doc.qt.io/qt-5/qml-qtquick-controls2-stackview.html#methods
see also
https://doc.qt.io/qt-5/qml-qtquick-controls2-swipeview.html -
hi
@Saeed_Nowroozi said in How to change the page in QML?:
but this do not correct. When push button , new page overlap on base page
that is the normal behavior of the stackView, you can push pages to it and it will stack them. You can also decide to remove (pop()) one page before you push a new one. See here everithing you can do https://doc.qt.io/qt-5/qml-qtquick-controls2-stackview.html#methods
see also
https://doc.qt.io/qt-5/qml-qtquick-controls2-swipeview.htmlwrote on 18 Mar 2021, 04:30 last edited by@LeLev Thanks
3/3