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

ListView currentSection property not always updated

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • Not Evaluated
    • None
    • 4.8.4, 5.0.1
    • None
    • d31f965b72a1bb8aba0b846471780e90fcc895ba

    Description

      If a model modification does not trigger the refill logic in QDeclarativeListView the currentSection property is not updated correctly.

      The example illustrates the bug: When the first row is removed, the currentSection will still display "A".

      This problem does not occur in QtQuick 2.0.

      import QtQuick 1.1
      
      Rectangle {
        width: 360
        height: 360
      
        ListModel {
          id: m
          ListElement { text: "A" }
          ListElement { text: "B" }
          ListElement { text: "C" }
          // a refill will hide the bug, so not too many elements here
        }
      
        ListView {
          id: lv
          anchors.fill: parent
          model: m
          section.property: "text"
          section.delegate: Text {
            text: section
            font.pixelSize: 20
            font.bold: true
            color: "green"
          }
      
          delegate: Text {
            font.pixelSize: 20
            text: model.text
          }
        }
      
        Text {
          anchors { right: parent.right; top: parent.top }
          text: lv.currentSection
          color: "red"
        }
      
        Text {
          text: "Click to Remove row"
          anchors { right: parent.right; bottom: parent.bottom }
          MouseArea {
            anchors.fill: parent
            onClicked: m.remove(0)
          }
        }
      }
      

      Attachments

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

        Activity

          People

            njeisecke Nils Jeisecke
            njeisecke Nils Jeisecke
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes