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

regression ListView not updating count

    XMLWordPrintable

Details

    • 0a1d8fb26 (6.8.0), 43c2c4e9f (tqtc/lts-6.5.7), 101df5c2c (dev), 8971dc7ab (6.8), cfde91bea (tqtc/lts-6.5)

    Description

      When a ListView has an initial size of 0 it fails to process model changes correctly resulting in countChanged never getting emitted.

      I'm attaching a minimal example that makes visibility conditional on count>0. When running it through bin/qml it does not ever switch to visible because the count is always 0, despite the model growing every second.

      This broke in qtdeclarative 477c15def834bd49553c00b90f3a2006456ea931.

      Downstream report https://bugs.kde.org/show_bug.cgi?id=493266

      // SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
      // SPDX-FileCopyrightText: 2024 Harald Sitter <sitter@kde.org>
      
      import QtQuick
      import QtQuick.Layouts
      
      ColumnLayout {
          ListView {
              Layout.fillWidth: true
              Layout.preferredHeight: contentHeight // grow with content, initially 0
      
              visible: count > 0 // actual defect. countChanged never fires so this never turns true
      
              model: ListModel {
                  id: idModel
              }
      
              delegate: Text {
                  required property string name
                  text: name
              }
      
              Timer {
                  running: true
                  interval: 1000
                  repeat: true
                  onTriggered: idModel.append({name:"Hello"})
              }
          }
      }
      

      Attachments

        Issue Links

          For Gerrit Dashboard: QTBUG-129165
          # Subject Branch Project Status CR V

          Activity

            People

              mitch_curtis Mitch Curtis
              apachelogger Harald Sitter
              Votes:
              0 Vote for this issue
              Watchers:
              8 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: