Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-50274

StackView: replacing of the topmost item clears the whole stack

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P2: Important
    • 5.6.0
    • 5.6.0 Beta
    • Quick: Controls 2
    • None
    • Mageia Linux Cauldron, x86_64, gcc 5.3.1
    • cf58057988464f68e23c4d52598fd9de791f4af7

    Description

      If I replace the topmost item in the stack, all items that was in the stack are deleted from the stack.

      To reproduce, run test program and click on "Replace" button. It replaces the topmost item with the new item. Then click on "Pop" button. The first item should be displayed, but nothing happens.

      import QtQuick 2.5
      import QtQuick.Layouts 1.3
      import Qt.labs.controls 1.0
      
      ApplicationWindow {
          visible: true
          width: 640
          height: 480
      
          Component {
              id: firstComponent
      
              Item {
                  Text {
                      anchors.centerIn: parent
                      text: "The first item"
                  }
              }
          }
      
          Component {
              id: secondComponent
      
              Item {
                  Text {
                      anchors.centerIn: parent
                      text: "The second item"
                  }
              }
          }
      
          Component {
              id: newComponent
      
              Item {
                  Text {
                      anchors.centerIn: parent
                      text: "The new item"
                  }
              }
          }
      
          ColumnLayout {
              anchors.fill: parent
              spacing: 10
      
              StackView {
                  id: stackView
      
                  Layout.fillHeight: true
                  Layout.fillWidth: true
      
                  onDepthChanged: console.log("depth:", depth)
              }
      
              Row {
                  Layout.alignment: Qt.AlignHCenter
                  spacing: 10
      
                  Button {
                      text: "Replace"
                      onClicked: stackView.replace(stackView.get(1), newComponent)
                  }
      
                  Button {
                      text: "Pop"
                      onClicked: stackView.pop()
                  }
              }
          }
      
          Component.onCompleted: stackView.push([ firstComponent, secondComponent ])
      }
      

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            krnekit Nikita Krupenko
            krnekit Nikita Krupenko
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes