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

ListView Binding Loop when setting width to contentWidth with LayoutMirroring enabled

    XMLWordPrintable

Details

    Description

      When using a ListView horizontally with layout mirroring enabled, adding data to the ListModel dynamically creates a binding loop if the width is bound to contentWidth to calculate the ListView's size.

      import QtQuick 2.5
      import QtQuick.Controls 2.5
      
      Item {
          id: root
          width: 800
          height: 200
      
          ListModel {
              id: _listModel
              Component.onCompleted: {
                  ['Monday',
                   'Tuesday',
                   'Wednesday',
                   'Thursday',
                   'Friday'].map(function(e) { append({"text":e});});
              }
          }
      
          ListView {
              id: _list
              width: contentWidth
              height: 50
              anchors.centerIn: parent
              Rectangle {
                  color: "red"
                  opacity: 0.2
                  anchors.fill: parent
              }
      
              orientation: ListView.Horizontal
              LayoutMirroring.enabled: true
              model: _listModel
      
              delegate: Rectangle {
                  width: label.implicitWidth + 20
                  height: label.implicitHeight
                  border.color: "black"
                  border.width: 2
                  
                  Text {
                      id: label
                      text: model.text
                      anchors.horizontalCenter: parent.horizontalCenter
                      font.pixelSize: 20
                  }
              }
          }
      }
      

      Attachments

        Issue Links

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

          Activity

            People

              edcooke Ed Cooke
              stephenpiazza Stephen Piazza
              Votes:
              1 Vote for this issue
              Watchers:
              10 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There is 1 open Gerrit change