Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. How to enter different StackViews

How to enter different StackViews

Scheduled Pinned Locked Moved Solved QML and Qt Quick
7 Posts 3 Posters 2.4k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    dauuser
    wrote on last edited by A Former User
    #1

    Hy @all

    I have a question about the navigation with StackViews and SwipeViews. On the following image (http://imgur.com/a/q8JAw) you can see the structure of my project. There's the main.qml which contains the "main" StackView. This Stackview has two children, the mainPage.qml and the additionalPage.qml. In this pages there are also some StackViews/SwipeViews, I think it's easy to unterstand when you are looking at the picture. Okay, so if I'm in the SwipeView of the mainPage.qml (DashPage for example) and now I want to jump to, let's say settingsPage.qml which is a children of the StackView in additionalPage.qml. How am I able to do this?
    I can't call the StackView via "Id" from the mainPage.qml. How can I solve this?

    Thanks in advance!

    Link to the image
    http://imgur.com/a/q8JAw

    1 Reply Last reply
    0
    • sneubertS Offline
      sneubertS Offline
      sneubert
      wrote on last edited by
      #2

      Declare some singals in your qmls and react to them in main.qml
      e.g in mainPage.qml:
      signal jumpToSettings() and emit it when ever needed.
      In main.qml add a singal handler to the mainPage object like:
      onJumpToSettings(): { //stack.push() ... }

      D 1 Reply Last reply
      1
      • sneubertS sneubert

        Declare some singals in your qmls and react to them in main.qml
        e.g in mainPage.qml:
        signal jumpToSettings() and emit it when ever needed.
        In main.qml add a singal handler to the mainPage object like:
        onJumpToSettings(): { //stack.push() ... }

        D Offline
        D Offline
        dauuser
        wrote on last edited by
        #3

        @sneubert said in How to enter different StackViews:

        Declare some singals in your qmls and react to them in main.qml
        e.g in mainPage.qml:
        signal jumpToSettings() and emit it when ever needed.
        In main.qml add a singal handler to the mainPage object like:
        onJumpToSettings(): { //stack.push() ... }

        and how can I access the StackView in additionalPage.qml when I'm in main.qml?

        1 Reply Last reply
        0
        • sneubertS Offline
          sneubertS Offline
          sneubert
          wrote on last edited by
          #4

          declare a function like function showSettings()in additionalPage.qml, where you push the settingsPage in additionalPage StackView. in main.qml signal handler you can then

          onJumpToSettings: {
          mainStackView.push(additionalPage);
          additionalPage.showSettings();
          }
          
          D 1 Reply Last reply
          1
          • sneubertS sneubert

            declare a function like function showSettings()in additionalPage.qml, where you push the settingsPage in additionalPage StackView. in main.qml signal handler you can then

            onJumpToSettings: {
            mainStackView.push(additionalPage);
            additionalPage.showSettings();
            }
            
            D Offline
            D Offline
            dauuser
            wrote on last edited by
            #5

            @sneubert said in How to enter different StackViews:

            declare a function like function showSettings()in additionalPage.qml, where you push the settingsPage in additionalPage StackView. in main.qml signal handler you can then

            onJumpToSettings: {
            mainStackView.push(additionalPage);
            additionalPage.showSettings();
            }
            

            ah, so the syntax to access the function is nameOfQMLFile**.**something.
            but I can only access the functions of the root item in a qml file right?

            1 Reply Last reply
            0
            • E Offline
              E Offline
              Eeli K
              wrote on last edited by
              #6

              So, basically your question isn't about stack view or swipe view at all, but about how to access inner components when they are in their own files and not directly visible outside? Basically you have to travel through the hierarchy and delegate the access in one way or another as many times/levels as needed. Functions, as sneubert told above, are one way. Another way is to use properties and aliases. You can make inner component visible outside by declaring alias for it. Then you can access all properties of that exposed component. Or you can declare extra property in outer component and create a binding so that inner component's property is bind to outer component's property value. So basically with properties there are two ways:

              1. From outside handle an inner component directly by making it visible (recursively).
              2. From outside change a property value of the top level component so that it's propagated downwards to inner component (recursively).

              If you have structure A { B { C{}} but each are in their own files and A can't see C, either you make C visible to A through B by declaring an alias for C in B, or you make a simple property in B and bind the wanted property in C to it.

              If you have A, B, C, D and so on your have to add more levels of propagation.

              I think this is one of the more tedious features of QML. If you have stucture A { B { C{}} in one file you can easily access C's properties from A, but if you make C a component you have to write extra code. If you want to customize one value in a Quick Component, you have to write it all instead of just changing that value. You just have to learn to live with it.

              D 1 Reply Last reply
              2
              • E Eeli K

                So, basically your question isn't about stack view or swipe view at all, but about how to access inner components when they are in their own files and not directly visible outside? Basically you have to travel through the hierarchy and delegate the access in one way or another as many times/levels as needed. Functions, as sneubert told above, are one way. Another way is to use properties and aliases. You can make inner component visible outside by declaring alias for it. Then you can access all properties of that exposed component. Or you can declare extra property in outer component and create a binding so that inner component's property is bind to outer component's property value. So basically with properties there are two ways:

                1. From outside handle an inner component directly by making it visible (recursively).
                2. From outside change a property value of the top level component so that it's propagated downwards to inner component (recursively).

                If you have structure A { B { C{}} but each are in their own files and A can't see C, either you make C visible to A through B by declaring an alias for C in B, or you make a simple property in B and bind the wanted property in C to it.

                If you have A, B, C, D and so on your have to add more levels of propagation.

                I think this is one of the more tedious features of QML. If you have stucture A { B { C{}} in one file you can easily access C's properties from A, but if you make C a component you have to write extra code. If you want to customize one value in a Quick Component, you have to write it all instead of just changing that value. You just have to learn to live with it.

                D Offline
                D Offline
                dauuser
                wrote on last edited by dauuser
                #7

                @Eeli-K said in How to enter different StackViews:

                So, basically your question isn't about stack view or swipe view at all, but about how to access inner components when they are in their own files and not directly visible outside? Basically you have to travel through the hierarchy and delegate the access in one way or another as many times/levels as needed. Functions, as sneubert told above, are one way. Another way is to use properties and aliases. You can make inner component visible outside by declaring alias for it. Then you can access all properties of that exposed component. Or you can declare extra property in outer component and create a binding so that inner component's property is bind to outer component's property value. So basically with properties there are two ways:

                1. From outside handle an inner component directly by making it visible (recursively).
                2. From outside change a property value of the top level component so that it's propagated downwards to inner component (recursively).

                If you have structure A { B { C{}} but each are in their own files and A can't see C, either you make C visible to A through B by declaring an alias for C in B, or you make a simple property in B and bind the wanted property in C to it.

                If you have A, B, C, D and so on your have to add more levels of propagation.

                I think this is one of the more tedious features of QML. If you have stucture A { B { C{}} in one file you can easily access C's properties from A, but if you make C a component you have to write extra code. If you want to customize one value in a Quick Component, you have to write it all instead of just changing that value. You just have to learn to live with it.

                Thanks, this helped a lot and was the crunchpoint of my problem.

                1 Reply Last reply
                0

                • Login

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • Users
                • Groups
                • Search
                • Get Qt Extensions
                • Unsolved