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

ListModel move() operation isn't correctly reflected in views sometimes

    XMLWordPrintable

Details

    Description

      In this particular case the issue arises when moving multiple items backwards in a list. For example, if a model contains ['a', 'b', 'c'] then calling move(1, 0, 2) should move the last two items to the start of the list, resulting in ['b', 'c', 'a']. Instead, it results in ['b','a'] and 'c' is missing.

      The problem is in the views / VisualDataModel; inspection of the list model reveals that 'c' is still in the model, but is just not visible in the view.

      ListView {
          width: 300; height: 200
          model: ListModel {
              ListElement { value: 'a' }
              ListElement { value: 'b' }
              ListElement { value: 'c' }
          }
      
          delegate: Rectangle {
              width: 40; height: 40
              border.width: 1
      
              Row {
                  Text { text: index }
                  Text { text: value; font.pixelSize: 20 }
              }
          }
      
          Component.onCompleted: {
              model.move(1, 0, 2)
          }
      }
      

      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:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes