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

ListView sometimes doesn't lay out items correctly following delayed view transitions

    XMLWordPrintable

Details

    • d290cb3a499a0c3a71ab1f63cbd2fc45b0f5835f

    Description

      Run the following code and press keys "2" and "3" quickly to rapidly insert then remove the same index. If the removal is performed before the add displaced animation has animated all of the items in the view, the layout is not performed correctly, and somewhere in the view there will be a blank space in a spot where an item should be.

      This doesn't happen if the PauseAnimation is removed.

      import QtQuick 2.0
      
      Item {
          width: 300; height: 400
      
          ListView {
              id: view
              anchors.fill: parent
              anchors.margins: 30
      
              model: ListModel {
                  ListElement { name: "A" }
                  ListElement { name: "B" }
                  ListElement { name: "C" }
                  ListElement { name: "D" }
                  ListElement { name: "E" }
                  ListElement { name: "F" }
              }
              delegate: Rectangle {
                  width: 200; height: 30
                  border.width: 1
                  color: ListView.isCurrentItem ? "yellow" : "lightsteelblue"
                  objectName: name
      
                  Text { text: name + " " + parent.y; anchors.centerIn: parent }
              }
      
              focus: true
              Keys.onDigit2Pressed: model.insert(1, {"name": "New item"})
              Keys.onDigit3Pressed: model.remove(1)
      
              add: Transition {
                  NumberAnimation { properties: "x,y"; duration: 1000}
              }
              addDisplaced: Transition {
                  id: addDisplaced
                  SequentialAnimation {
                      PauseAnimation { duration: addDisplaced.ViewTransition.index * 200 }
                      NumberAnimation { properties: "x,y"; duration: 1000; easing.type: Easing.OutBounce }
                  }
              }
              removeDisplaced: Transition {
                  NumberAnimation { properties: "x,y"; duration: 1000}
              }
          }
      }
      

      Attachments

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

        Activity

          People

            bealam Bea Lam (closed Nokia identity) (Inactive)
            bealam Bea Lam (closed Nokia identity) (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes