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. confuse stackview when push and pop (also replace) quickly. (qtquick.controls2)

confuse stackview when push and pop (also replace) quickly. (qtquick.controls2)

Scheduled Pinned Locked Moved Solved QML and Qt Quick
8 Posts 4 Posters 451 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.
  • MohsenNzM Offline
    MohsenNzM Offline
    MohsenNz
    wrote on last edited by MohsenNz
    #1

    Hi. I have a important problem with stack view. when you push and pop items quickly to stack view (for example with tabbar) the stackView confused and show empty. see video : https://youtu.be/j5qpsHcBxHk
    source code: https://paste.ubuntu.com/p/bB9pnJGNCf/

    1 Reply Last reply
    0
    • David_001D Offline
      David_001D Offline
      David_001
      wrote on last edited by
      #2

      Hi,
      could it be, that you will get out of Range?
      Try to add a logic at onClicked to avoid going under index == 0;

      Never seen that bevor

      MohsenNzM 1 Reply Last reply
      0
      • David_001D David_001

        Hi,
        could it be, that you will get out of Range?
        Try to add a logic at onClicked to avoid going under index == 0;

        Never seen that bevor

        MohsenNzM Offline
        MohsenNzM Offline
        MohsenNz
        wrote on last edited by MohsenNz
        #3

        @david_001
        u can use buttons instead tabbar and see this problem again.

        1 Reply Last reply
        0
        • IntruderExcluderI Offline
          IntruderExcluderI Offline
          IntruderExcluder
          wrote on last edited by
          #4

          Can you try this:

          ApplicationWindow {
              visible: true
              width: 640
              height: 480
              title: qsTr("Hello World")
          
              StackView {
                  id: stackView
                  anchors.fill: parent
                  initialItem: page1
              }
          
              TabBar {
                  id: tabBar
                  anchors.bottom: parent.bottom
                  width: parent.width
                  TabButton {
                      text: qsTr("Page1")
                      onClicked: stackView.pop()
                  }
          
                  TabButton {
                      text: qsTr("Page2")
                      onClicked: {
                          if (stackView.depth === 1)
                              stackView.push(page2)
                      }
                  }
              }
          
              Component {
                  id: page1
                  Rectangle {
                      color: "lightBlue"
                      Text { anchors.centerIn: parent; text: "Page1" }
                  }
              }
          
              Component {
                  id: page2
                  Rectangle {
                      color: "lightGreen"
                      Text { anchors.centerIn: parent; text: "Page2" }
                  }
              }
          }
          

          Cannot reproduce when using Component. It seems that with your code pop transition is still incomplete and you are trying to push the same item which is currently being popped.

          MohsenNzM 2 Replies Last reply
          1
          • IntruderExcluderI IntruderExcluder

            Can you try this:

            ApplicationWindow {
                visible: true
                width: 640
                height: 480
                title: qsTr("Hello World")
            
                StackView {
                    id: stackView
                    anchors.fill: parent
                    initialItem: page1
                }
            
                TabBar {
                    id: tabBar
                    anchors.bottom: parent.bottom
                    width: parent.width
                    TabButton {
                        text: qsTr("Page1")
                        onClicked: stackView.pop()
                    }
            
                    TabButton {
                        text: qsTr("Page2")
                        onClicked: {
                            if (stackView.depth === 1)
                                stackView.push(page2)
                        }
                    }
                }
            
                Component {
                    id: page1
                    Rectangle {
                        color: "lightBlue"
                        Text { anchors.centerIn: parent; text: "Page1" }
                    }
                }
            
                Component {
                    id: page2
                    Rectangle {
                        color: "lightGreen"
                        Text { anchors.centerIn: parent; text: "Page2" }
                    }
                }
            }
            

            Cannot reproduce when using Component. It seems that with your code pop transition is still incomplete and you are trying to push the same item which is currently being popped.

            MohsenNzM Offline
            MohsenNzM Offline
            MohsenNz
            wrote on last edited by
            #5

            @intruderexcluder
            Thank you man. it's work .
            I will use component from now ;)

            1 Reply Last reply
            0
            • IntruderExcluderI IntruderExcluder

              Can you try this:

              ApplicationWindow {
                  visible: true
                  width: 640
                  height: 480
                  title: qsTr("Hello World")
              
                  StackView {
                      id: stackView
                      anchors.fill: parent
                      initialItem: page1
                  }
              
                  TabBar {
                      id: tabBar
                      anchors.bottom: parent.bottom
                      width: parent.width
                      TabButton {
                          text: qsTr("Page1")
                          onClicked: stackView.pop()
                      }
              
                      TabButton {
                          text: qsTr("Page2")
                          onClicked: {
                              if (stackView.depth === 1)
                                  stackView.push(page2)
                          }
                      }
                  }
              
                  Component {
                      id: page1
                      Rectangle {
                          color: "lightBlue"
                          Text { anchors.centerIn: parent; text: "Page1" }
                      }
                  }
              
                  Component {
                      id: page2
                      Rectangle {
                          color: "lightGreen"
                          Text { anchors.centerIn: parent; text: "Page2" }
                      }
                  }
              }
              

              Cannot reproduce when using Component. It seems that with your code pop transition is still incomplete and you are trying to push the same item which is currently being popped.

              MohsenNzM Offline
              MohsenNzM Offline
              MohsenNz
              wrote on last edited by
              #6
              This post is deleted!
              IntruderExcluderI 1 Reply Last reply
              0
              • MohsenNzM MohsenNz

                This post is deleted!

                IntruderExcluderI Offline
                IntruderExcluderI Offline
                IntruderExcluder
                wrote on last edited by
                #7

                @mohsennz said in confuse stackview when push and pop (also replace) quickly. (qtquick.controls2):

                @intruderexcluder
                now how can i mark this as solved?

                Not sure, probably by editing original post.

                1 Reply Last reply
                0
                • J.HilkJ Offline
                  J.HilkJ Offline
                  J.Hilk
                  Moderators
                  wrote on last edited by
                  #8

                  right hand side -> topic tools -> mark as solved


                  Be aware of the Qt Code of Conduct, when posting : https://forum.qt.io/topic/113070/qt-code-of-conduct


                  Q: What's that?
                  A: It's blue light.
                  Q: What does it do?
                  A: It turns blue.

                  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