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

ListView result is incorrect after inserting before visible and moving a following index

    XMLWordPrintable

Details

    • 52c1d7a994216f0b37ac04a2fea4337bc0c7550b

    Description

      With the following code, execute this sequence of key presses:

      1) Enter (set contentY to 80)
      2) Return (insert an item at 0)
      3) Space (move with (1,6,3) parameters)

      Observe the resulting indexes in view are out of sequence, and there is a gap in the second slot. (Attached as actual.png)

      import QtQuick 2.0
      
      Item {
          width: 600; height: 600
      
          ListView {
      
              id: view2
              width: 240; height: 320
              x: 100
              y: 100
      
              model: ListModel {
                  id: model2
                  Component.onCompleted: {
                      for (var i=0; i<30; i++) {
                          append({'name': 'item ' + i})
                      }
                  }
              }
              delegate: Rectangle {
                  border.width: 1
      
                  width: 200; height: 20;
                  Row {
                      Text { text: name + " : " + index + " : " }
                      Text { text: " " + parent.parent.x + ", " + parent.parent.y }
                  }
                  objectName: name
              }
      
              focus: true
      
              Keys.onEnterPressed: {
                  contentY = 80
              }
      
              Keys.onReturnPressed: {
                  model.insert(0, {"name": "new item" })
              }
      
              Keys.onSpacePressed: {
                  model.move(1, 6, 3)
              }
      
          }
      
          Rectangle {
              anchors.fill: view2
              color: "lightsteelblue"
              opacity: 0.3
      
          }
          Text { anchors.right: parent.right; text: "content y:" + view2.contentY + ", count: " + model2.count }// + " " + view2.count }
      
      }
      

      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