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

ListView: contentY is wrong when first item is removed

    XMLWordPrintable

Details

    • Bug
    • Resolution: Out of scope
    • Not Evaluated
    • None
    • 4.7.3
    • None
    • Ubuntu 10.04 (64 bit)

    Description

      When the first item in a ListView is removed as in the example below, the real contentY property value gets increased by #removedItems * (itemHeight + spacing).

      import QtQuick 1.0
      
      ListView {
          id: listView
      
          height: 300; width: 200
          spacing: 5
      
          model: ListModel {
              id: listModel
              ListElement { }
              ListElement { }
              ListElement { }
              ListElement { }
              ListElement { }
              ListElement { }
          }
      
          delegate: Rectangle {
              height: 90
              width: listView.width
              color: "#5D91DB"
      
              Text {
                  anchors.centerIn: parent
                  text: model.index
              }
          }
      
          Component.onCompleted: {
              // bug occurs only if first item is removed
              listModel.remove(0)
              // listModel.remove(0)
          }
      
          // (contentY - correctContentY) ≈ #removedItems * (itemHeight + spacing)
          property int correctContentY: Math.ceil(visibleArea.yPosition * contentHeight)
      
          onContentYChanged:
              console.log("contentY: "              + contentY +
                          ",   correctContentY: "   + correctContentY +
                          "    (difference: "         + (contentY - correctContentY) + ")\n" +
                          "visibleArea.yPosition: " + visibleArea.yPosition +
                          ",   atYBeginning: "      + atYBeginning +
                          ",   atYEnd: "            + atYEnd + "\n")
      }
      

      (Scroll ListView to get debug output)

      Attachments

        Issue Links

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

          Activity

            People

              brasser Michael Brasser (closed Nokia identity) (Inactive)
              hiddenbit Michael Scholtz
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes