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

Tumbler sometimes ignores specified index

XMLWordPrintable

      import QtQuick 2.15
      import QtQuick.Controls 2.15
      
      ApplicationWindow {
          width: 640
          height: 480
          visible: true
      
          readonly property int n: 10
      
          Tumbler
          {
              id: tumbler
              wrap: false
              currentIndex: n-2
              model: n
          }
      
          Component.onCompleted: console.log("Current index is", tumbler.currentIndex)
      }
      

       

      Expected output

      qml: Current index is 8
      

       

      Actual output

      qml: Current index is 7
      

       

      Problem scope

      • The issue persists even if we change the value of n
      • The issue does not occur if tumbler.wrap == true
      • The issue does not occur if the initial value of tumbler.currentIndex != n-2
      • The issue does not occur with Qt 6.2.6 and 6.4.0

       

      Workaround
      Instead of setting currentIndex declaratively, assign the desired value in the Component.onCompleted signal handler of the parent window:

      Component.onCompleted: tumbler.currentIndex = n-2
      

      This workaround must be applied to the parent window, not to the Tumbler itself.

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

            hurlevent Oliver Eftevaag
            skoh-qt Sze Howe Koh
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes