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

positionViewAtIndex() from Component.onCompleted doesn't Center

    XMLWordPrintable

Details

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

    Description

      The following minimal example doesn't do what I think it's supposed to do:

      import QtQuick 2.15
      import QtQuick.Window 2.15
      
      Window {
          width: 640
          height: 480
          visible: true
          title: qsTr("Hello World")
      
          ListView {
              id: lv
      
              anchors.fill: parent
      
              model: 1000
              clip: true
              delegate: Text {
                  width: lv.width
                  text: index
              }
              // Doesn't center - the 500th delegate as at the viewport edge
              Component.onCompleted: positionViewAtIndex(500, ListView.Center)
          }
      }
      

      Am I missing something obvious?

      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:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes