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

Forums

OverviewFelgo 2 Support (Qt 5) › Added Navigation menu to the cpp qml integration example and got error

Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #21392

    Flesh

    I took this example:

    https://felgo.com/doc/felgo-appdemos-cpp-qml-integration-example/

    and added a Navigation menu like

    App {
        Page {
            id: mainPage
            title: qsTr("Example of C++ Integratation")
            visible: true
    
            Navigation {
                id: navigation
    
                NavigationItem {
                    title: qsTr("Page 1")
                    icon: IconType.list
                    // NavigationStack
                    NavigationStack {
                        initialPage: Page1 { }
                    } // end NavigationStack
                } // end NavigationItem
    
                NavigationItem {
                    title: qsTr("Page 2")
                    icon: IconType.calculator
                    // NavigationStack
                    NavigationStack {
                        initialPage: Page2 { }
                    } // end NavigationStack
                } // end NavigationItem
            } // end Navigation
        } // end Page
    } // end App
    

    I get the error:

    qrc:/qml/VPlayApps/navigation/NavigationItem.qml:243:5: QML Icon: Cannot anchor to an item that isn’t a parent or sibling.

    qrc:/qml/VPlayApps/controls/Icon.qml:70:3: QML QQuickText: Cannot anchor to an item that isn’t a parent or sibling.

    It crashes when I run the debug run, not Live.

    Page1 and Page2 look like:

    import Felgo 3.0
    import QtQuick 2.0
    Page {
        id: page1
        title: qsTr("Page 1")
    
    } // end Page

    Shadow build on or off id not help.

    Thanks for any help

    #21397

    Alex
    Felgo Team

    Hi,

    Page components are not meant to be nested inside each other. Please remove the wrapping “mainPage” component. The Navigation will show the page of the first NavigationItem as the initial page.

    Cheers,
    Alex

    #21404

    Flesh

    Is the example wrong, if so it needs to be fixed, but it did not solve the problem, if I only have 1 NavigationItem it does not crash, but with 2 it crashes.

    Please try running the example, and you will see, I first got the orignal example running, then added Page1 and Page2, and then the Navigation Menu, first with one NavigationItem, then two, and the second one crashes.

    #21405

    Flesh
    #21407

    Alex
    Felgo Team

    Hi,

    the Page1.qml of your example holds a whole app, including the App root component and a NavigationStack.

    So effectively your structure is App -> Navigation -> NavigationItem -> NavigationStack -> App -> NavigationStack -> Page while the bold part should only be a Page instead.

    Cheers,
    Alex

    #21411

    Flesh

    Originally I did not make that mistake, but that did fix this issue, so my other issue must be in that page, and I did not make this mistake on that page, page is the top component, so it has something to do with my program, and not the fact it is in a navigation item, that is good to know, it narrows it down a little, I update the github example to a working example, because I like a lot of examples on how to do things.

    Thanks

Viewing 6 posts - 1 through 6 (of 6 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