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

Moving items doesn't reposition items correctly if moving from outside of view

    XMLWordPrintable

Details

    Description

      With the following code, scroll down until the content y is 60, then press the space key to execute a move(1, 6, 1).

      As a result:

      • The first item is Item 4, when actually Item 3 should be first
      • Item 4 has an empty space beneath it
      • Item 1 has not moved to below Item 6 as it should

      The issue doesn't arise if we set the contentY programmatically instead of flicking (which does a refill).

      See attached actual.png and expected.png (expected.png shows the result of just setting contentY -> 60 and then doing the move).

      import QtQuick 2.0
      
      Item {
          width: 500; height: 500
      
          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 {
                  width: 200; height: 20; border.width: 1
                  Row {
                      Text { text: name + " : " + index + " : " }
                      Text { text: " " + parent.parent.x + ", " + parent.parent.y }
                  }
                  objectName: name
              }
      
              focus: true
              Keys.onSpacePressed: {
                  model.move(1, 6, 1)
              }
          }
      
          Rectangle {
              anchors.fill: view2
              color: "lightsteelblue"
              opacity: 0.3
      
          }
          Text { anchors.right: parent.right; text: "content y:" + view2.contentY + ", count: " + model2.count }
      
      }
      

      Attachments

        1. actual.png
          actual.png
          51 kB
        2. actual-030712.png
          actual-030712.png
          66 kB
        3. expected.png
          expected.png
          53 kB
        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:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes