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

StackLayout doesn't handle Repeaters with async loading

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 6.5.5
    • Quick: Layouts
    • None

    Description

      Asyncronous loading can cause QML components to complete in different orders, by design. The StackLayout seems to be dependent on this initialization order which can cause the wrong item to be shown.

      Reproducible example:

      import QtQuick
      import QtQuick.Window
      import QtQuick.Layouts
      
      Window {
          width: 640
          height: 480
          visible: true
          title: qsTr("Hello World")
      
          Loader {
              asynchronous: true
              sourceComponent: StackLayout {
                  id: sl
                  currentIndex: 0
                  anchors.fill: parent
      
                  Repeater {
                      model: 10
                      Text {
                          text: `${index}: ${StackLayout.index} - ${sl.currentIndex}`
                          color: "black"
      
                          Component.onCompleted: console.log("created", index)
                      }
                  }
              }
          }
      }
      

      Causes:

      When setting asynchronous: false you get the expected behavior:

      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
            jhuels20 Joshua Huels
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes