Learn what Felgo offers to help your business succeed. Start your free evaluation today! Felgo for Your Business

Forums

OverviewFelgo 3 Support (Qt 5) › Navigation Stack Push

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #24659

    Ravi

    Hi

     

    I just installed Felgo and am going through the first example code on navigation from one page to another.

    I followed the example code but there is an error.

    Page 1: 
    
    App {
    
      NavigationStack {
        id:page
        Page {
          title: qsTr("Page 1")
    
          AppText {
            id: myText
            text: "Welcome to Felgo"
            //anchors.centerIn: parent
            anchors.horizontalCenter: parent.horizontalCenter
            anchors.bottom: parent.bottom
          }
    
          AppImage {
              anchors.horizontalCenter: myText.horizontalCenter
              anchors.bottom: myText.top
    
              source: "../assets/felgo-logo.png"
          }
    
          AppButton{
              anchors.horizontalCenter: parent.horizontalCenter
              text: "Page 2"
    
              onClicked: {
                  page.navigationStack.push(Qt.resolvedUrl("DetailPage.qml"))
                 // NavigationStack.push((Qt.resolvedUrl("DetailPage.qml")))
              }
          }
        }
      }
    }
    
    Page 2:
    
    Page {
      id:page
      title: "Detail Page"
    
      AppText {
        text: "Second Page"
        anchors.centerIn: parent
      }
    }
    
    
    

    I cant seem to navigate to the second page.

    I tried

    page.NavigationStack.push and NavigationStack.push

     

    The error log is this:

    file:///C:/…./Felgo Live Client/AppPlayground/qml/Main.qml:31: TypeError: Cannot call method ‘push’ of undefined

     

    Please let me know how to resolve this issue.

     

    Thanks!

    #24661

    Bence
    Felgo Team

    Hi Ravi,

    The id of your navigation stack is “page”, which means you can call the push method simply by typing:

    page.push(nextPage)

    It might be a good idea to rename this navigation stack id to something more unique (as Page2 also has the id “page”), for example “navStack”.

    Best,

    Bence

Viewing 2 posts - 1 through 2 (of 2 total)

RSS feed for this thread

You must be logged in to reply to this topic.

Qt_Technology_Partner_RGB_475 Qt_Service_Partner_RGB_475_padded