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

ListView: Calling `positionViewAtIndex(idx)` followed by `currentIndex=idx` causes animation glitches later

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 6.5.8, 6.8.2, 6.9.0 Beta2
    • None
    • Windows 10 22H2

    Description

      Code

      import QtQuick
      import QtQuick.Controls.Basic
      
      Window {
          id: root
          width: 640
          height: 480
          visible: true
      
          property int lastIndex: 4
      
          Column {
              ListView {
                  id: listView
                  width: 100
                  height: 200
                  model: root.lastIndex + 1
                  currentIndex: root.lastIndex
                  clip: true
                  delegate: Label {
                      required property int index
                      width: ListView.view.width
                      height: ListView.view.height
                      text: index
                      verticalAlignment: Qt.AlignVCenter
                  }
              }
              Button {
                  text: "Decrement"
                  onClicked: listView.currentIndex--
              }
              Button {
                  text: "Slow Reset"
                  onClicked: listView.currentIndex = root.lastIndex
              }
              Button {
                  text: "Fast Reset 1"
                  onClicked: {
                      listView.currentIndex = root.lastIndex
                      listView.positionViewAtIndex(root.lastIndex, ListView.Beginning) // OR positionViewAtEnd()
                  }
              }
              Button {
                  text: "Fast Reset 2"
                  onClicked: {
                      listView.positionViewAtIndex(root.lastIndex, ListView.Beginning) // OR positionViewAtEnd()
                      listView.currentIndex = root.lastIndex
                  }
              }
          }
      }
      

       

      Steps to reproduce
      In the steps below, wait for the animations to complete before making the next click:

      1. Build and run the code above
      2. Click "Decrement" repeatedly until the view reaches 0
      3. Click "Slow Reset"
      4. Click "Decrement" repeatedly until the view reaches 0
      5. Click "Fast Reset 1"
      6. Click "Decrement" repeatedly until the view reaches 0
      7. Click "Fast Reset 2"
      8. Click "Decrement" repeatedly until the view reaches 0

       

      Outcomes

      • (Steps #2, #4, #6) Each click smoothly animates to the next item (Expected)
      • (Step #3) The view smoothly animates to "4" (Expected)
      • (Steps #5, #7) The view quickly snaps to "4" (Expected)
      • (Step #8) The first 2 clicks abruptly jump to the next item (Not Expected); the remaining clicks behave as expected

      "Fast Reset 1" and "Fast Reset 2" perform the same operations, just in different orders. Neither should be considered wrong.

      Attachments

        Issue Links

          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
              skoh-qt Sze Howe Koh
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes