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

ListView children having QQuickItem type instead of expected type

    XMLWordPrintable

Details

    • Windows

    Description

      When referencing a listview's contentItem.children[index] property, if the ListView's dimensions are not concretely defined or not large enough to simultaneously display all the delegates, one of the children will be listed as a QQuickItem regardless of if the actual corresponding delegate is a QQuickItem or not.

      import QtQuick
      import QtQuick.Controls
      
      ApplicationWindow {
          width: 640
          height: 480
          visible: true
          title: qsTr("Hello World")
      
          ListView {
              id: testList
              model: 20
              cacheBuffer: 1000
              spacing: 2
      
              /*The following results in the 2nd delegate showing up as a QQuickItem in the list of children of the ListView*/
              anchors.fill: parent
      
              /*The following results in the delegate with the issue not being the 2nd but the first delegate that is not at least partially visible within the defined height of the ListView
      //        height: 400
      //        width: 400
      
      
              /*The following results in no issues at all with the list of children*/
      //        height: 1000
      //        width: 400
      //        Component.onCompleted: anchors.fill = parent
      
              delegate: Button {
                  width: ListView.view.width
                  height: 30
                  text: index
                  Component.onCompleted: {
                      console.log("Index " + index + " is listed as a " + testList.contentItem.children[index].toString())
      
                  }
                  onClicked: console.log("This is button number " + index + " functioning properly")
              }
          }
      }
      

      See attached file for the full sample project.

      Attachments

        Issue Links

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

          Activity

            People

              mitch_curtis Mitch Curtis
              kevin.zhang Kevin Zhang
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes