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 Identify an Item which i am going to push in stackview is already existed in stackview's stack ?

How to Identify an Item which i am going to push in stackview is already existed in stackview's stack ?

Scheduled Pinned Locked Moved Solved QML and Qt Quick
3 Posts 2 Posters 432 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
    divaindie
    wrote on last edited by
    #1

    Hi All,
    assume that i have multiple "page" items and a "StackView" as shown below.
    i want to achieve something like , if i have already pushed 'page1' and if i have to push it one more time i have to search weather this particular 'page' already existed in the "StackView" tree ,if it is there i want to make that particular Item as top item in "StackView",if it is not there i will push that particular "page"
    How i can achieve this ??

    Component{
          id:page1
          Page{........}
    }
    Component{
          id:page2
          Page{........}
    }
    Component{
          id:page3
          Page{........}
    }
    StackView
    {
    id:sv
    initialItem: page1
    
    }
    
    1 Reply Last reply
    0
    • ODБOïO Offline
      ODБOïO Offline
      ODБOï
      wrote on last edited by ODБOï
      #2

      Hi,
      @divaindie said in How to Identify an Item which i am going to push in stackview is already existed in stackview's stack ?:

      achieve

      ApplicationWindow {
          id: window
          visible: true
          width: 600
          height: 200
          Component{
              id:page1
              Rectangle{
                  color: "red"
              }
          }
          Component{
              id:page2
              Rectangle{
                  color: "green"
              }
          }
          Component{
              id:page3
              Rectangle{
                  color:"blue"
              }
          }
          property variant  pages : [page1,page2,page3]
      
          function setMenu(ind){
              sv.push(pages[ind])
          }
      
          RowLayout{
              id:menuLayout
              Repeater{
                  model: pages.length
                  Button{
                      text: "menu " + index
                      onClicked: {
                          setMenu(index)
                      }
                  }
              }
          }
      
          StackView
          {
              id:sv
              initialItem: page1
              anchors{
                  top : menuLayout.bottom
                  left:parent.left
                  right:parent.right
                  bottom:parent.bottom
              }
          }
      }
      

      @divaindie said in How to Identify an Item which i am going to push in stackview is already existed in stackview's stack ?:

      search weather this particular 'page' already existed in the "StackView" tree ,if it is there i want to make that particular Item as top item in "StackView",if it is not there i will push that particular "page"

      you don't have to handle this

      1 Reply Last reply
      1
      • D Offline
        D Offline
        divaindie
        wrote on last edited by
        #3

        thanks !!!

        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