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

Changing the source component of a loader causes PropertyChanges target binding issue

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • 5.15.0
    • None
    • Microsoft Visual C++ Compiler 16.7.30413.136
    • Windows

    Description

      It looks as if when changing the source component of a loader, the target binding of PropertyChanges is destroyed and the target property is not changed anymore.

      In the following example, the initial text of the label is "Modified Label". After changing the source component, however, the text binding within the state is no longer applied.

      import QtQuick 2.15
      import QtQuick.Controls 2.15
      import QtQuick.Layouts 1.15
      
      ApplicationWindow {
          id: root
      
          visible: true
      	width: 800
          height: 600
      
          ColumnLayout {
              Loader {
                  id: loader
      
                  property bool firstLabel: true
                  readonly property Component label1: Label { text: "Label 1" }
                  readonly property Component label2: Label { text: "Label 2" }
                  readonly property Label label: loader.item ?? null
      
                  sourceComponent: firstLabel ? label1 : label2
      
                  StateGroup {
                      states: [
                          State {
                              when: loader.label !== null
      
                              PropertyChanges {
                                  target: loader.label
                                  text: "Modified Label"
                              }
                          }
                      ]
                  }
              }
              Switch {
                  onPressed: loader.firstLabel = !loader.firstLabel
              }
          }
      }
      
      

      Attachments

        For Gerrit Dashboard: QTBUG-87463
        # Subject Branch Project Status CR V

        Activity

          People

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            dmartin Daniel Martin
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes