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

Wrapping BottomToTop ListView with variably sized delegates in a ScrollView breaks positionViewAtIndex

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • 5.15.2
    • Quick: Other
    • None
    • RHEL 8.4
    • Linux/X11

    Description

      There are quite a few conditions to fulfil here; the minimal example with comments where I tried to reduce it follows:

      import QtQuick 2.15
      import QtQuick.Window 2.15
      import QtQuick.Controls 2.15
      
      Window {
          width: 640
          height: 480
          visible: true
          title: qsTr("Hello World")
      
          // Dropping ScrollView makes positioning work
          ScrollView {
              anchors.fill: parent
              clip: true
      
              ListView {
                  id: lv
      
                  model: 1000
      
                  // TopToBottom lists get positioned correctly even when in ScrollView
                  verticalLayoutDirection: ListView.BottomToTop
                  delegate: Text {
                      width: lv.width
                      text: index
                      // The variance in the delegate height is key to the effect;
                      // the formula below was just a way to vary the height.
                      // At smaller variances the 500th delegate may still be
                      // on the screen.
                      font.pixelSize: (index + 10) % 100
                  }
      
                  // The actual result is that the 500th delegate is not on the screen, the list view
                  // is positioned somewhere in 51x-52x range instead.
                  // ListView.Center is broken in a similar way.
                  // positionViewAtEnd() seems to work.
                  // positionViewAtBeginning() breaks differently -
                  // will file a separate bug for that.
                  Component.onCompleted: positionViewAtIndex(500, ListView.Contain)
              }
          }
      }
      

      Attachments

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

        Activity

          People

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            alexey.rusakov Alexey Rusakov
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes