Forums

OverviewFelgo 2 Support (Qt 5) › Losding the next page using Navigation

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #19832

    Gabor Toth

    Hi

    Based on the examples I wrote the following code:

    import QtQuick 2.4
    import QtQuick.Window 2.2
    import QtQuick.Controls 2.0 as Quick2
    import QtQuick.Layouts 1.3
    import Felgo 3.0
    
    App {
        Navigation {
            id: navigation
    
            NavigationItem {
                id: homescreen
                title: "Home"
                icon: IconType.home
    
                NavigationStack {
                    initialPage: page_1
    
                    Component {
                        id: uirstpage
    
    
                    Page {
    
                        id:mainpage
                        title: "Main Page"
                    }
                }
            }
    
            NavigationItem {
                title: "First Page"
    
    
                NavigationStack {
                    Page {
                        id: firstpage
                        title: "1st Page"
    
                        StackLayout {
                            id: stacklayout
                            width: parent.width
                            height: parent.height
                            anchors.bottom: parent.bottom
                            clip: true
    
                            page_1 {}
                        }
    
    
    }
            }
        }
    }
    }
    }
    

    The code only changes the page title,  but not loading the actual page.The Showcase demo loads the next page using

    AppComponentsPage { }
    ExamplePage { }

    where AppComponentsPage and ExamplePage are the actual file names. . When I use page_1 {} in my code nothing happens besides getting an error message “Cannot assign to nonexistent property ‘page_1′”. Please tell me what I am doing incorrectly.

    Thank you.

    #19833

    Alex
    Felgo Team

    Hi,

    the showcase app is rather advanced, you can find more basic examples for use-cases in our documentation. E.g. for your navigation you can look at: https://felgo.com/doc/apps-howto-use-app-navigation/#use-a-drawer-or-tabs-to-navigate

    There are several issues in your code:

    • You are missing a closing } in your first NavigationItem block. If you select your code (or select all with CTRL+A) you can automatically fix indentation with CTRL+I (that’s an i). This helps you spot such mistakes.
    • QML files need to start with a capital letter, if you want to use them as an item. E.g. Page_1.qml and then use it as Page_1 in your code. Qt tries to access page_1 as if it was a property of the StackLayout, because it starts with a small letter.
    • Your first NavigationStack looks very broken, with setting initialPage to an invalid id (or should this be an item, which would miss the parenthesis). Then creating a Page as Component which is not used. Please follow some basic examples from the documentation, like I posted above, this will make your life much easier!

    Cheers,
    Alex

    #19839

    Gabor Toth

    Thank you for your advice. I started to use the Tabbed Application Template and that solved my problem.

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

RSS feed for this thread

You must be logged in to reply to this topic.

Voted #1 for:

  • Easiest to learn
  • Most time saving
  • Best support

Develop Cross-Platform Apps and Games 50% Faster!

  • Voted the best supported, most time-saving and easiest to learn cross-platform development tool
  • Based on the Qt framework, with native performance and appearance on all platforms including iOS and Android
  • Offers a variety of plugins to monetize, analyze and engage users
FREE!
create apps
create games
cross platform
native performance
3rd party services
game network
multiplayer
level editor
easiest to learn
biggest time saving
best support