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

[REG 5.11-5.12.0] Setting ListView delegate's width to parent.width does not work inside ScrollView

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P1: Critical
    • 5.12.3, 5.13.2, 5.14.0 Alpha
    • 5.12.0
    • Quick: Controls 2
    • None
    • openSUSE Tumbleweed 20181224 x86_64
    • ff30fc5f5f637da6a06a33ae0e55d5e4b798099d (qt/qtquickcontrols2/5.12)

    Description

      The following QML code worked as expected producing a scrollable list of numbers in Qt 5.11, but produces a scrollable list of white space instead in Qt 5.12.0. The text is not visible because all ItemDelegates have zero width. Uncommenting either line (1) or line (3) works around the issue. However, explicitly setting contentWidth on ListView as in line (2) does not help.

      Tested on Linux using qmlscene.

      import QtQuick 2.11
      import QtQuick.Controls 2.4
      
      Item {
          width: 250
          height: 500
          
          ScrollView {
              anchors.fill: parent
              
      //         contentWidth: listView.contentWidth // workaround (1)
              
              ListView {
                  id: listView
                  
      //             contentWidth: width // not workaround (2)
                  
                  delegate: ItemDelegate {
      //                 implicitWidth: 0 // workaround (3)
                      width: parent.width
                      text: index
                  }
              }
          }
          
          Component.onCompleted: listView.model = 100
      }
      

      Attachments

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

        Activity

          People

            richard Richard Moe Gustavsen
            vovams Vova Mshanetskiy
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes