0

I have an application with several pages. One of them is a settings page where the user can select various settings. There are various buttons on the pages with which I can open the different pages.

Currently I always switch between the pages with:

page.navigationStack.push(nameOfPage)

For most cases this is okay, but when I close the settingspage, I want to go back to the previous page (the page that was opened when I pressed the button to open settingspage) and not have to specify 1 page.

I am working with QML/Felgo

code example: import Felgo 3.0 import QtQuick 2.0 import QtQuick.Controls 1.4

App {
    id: app
    NavigationStack {
        Page {
            id: page
            navigationBarHidden: true
            Text { text: qsTr("1st page") }
            Button {
                y: 30; text: "go to 2nd page"
                onClicked: page.navigationStack.push(secondpage)
            }
            Button {
                y: 60; text: "go to settings"
                onClicked: page.navigationStack.push(settingsPage)
            }
        }
    }

    Component {
        id: secondpage
        Page {
          navigationBarHidden: true
          Text { text: qsTr("2nd page") }
          Button {
              y: 30; text: "go to 1st page"
              onClicked: page.navigationStack.push(page)
          }
          Button {
              y: 60; text: "go to settings"
              onClicked: page.navigationStack.push(settingsPage)
          }
        }
    }

    Component {
        id: settingsPage
        Page {
            navigationBarHidden: true
            Text { text: qsTr("settings page") }
            //various settings
            Button {
                y: 30; text: "go to previous page"
                onClicked: page.navigationStack.push(page)  //??
            }
        }
    }
}

i dont know what to put for line 47 - so that I can get to either 1st or 2nd page - depending on where I opened settingspage from

any help would be really appreciated

1 Answers1

0

I think you want to use this method:

https://felgo.com/doc/felgo-navigationstack/#pop-method

This will perform the reverse animation (like hitting a back button in iOS or Android) and will remove and destroy the top Page on the stack.

David K. Hess
  • 16,632
  • 2
  • 49
  • 73