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

Initializing property through alias to bound bindable property fails

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P1: Critical
    • None
    • 6.5.3
    • None
    • 0fdf9042c (dev), 3ea55bf39 (dev), c07f63d06 (6.6), 7326d41be (6.6), dc4bd4fb3 (tqtc/lts-6.5), 11045230c (tqtc/lts-6.5), 6b43739ad (tqtc/lts-6.2), c850ac5cc (tqtc/lts-6.2)

    Description

      In the following code the object name of the "child" item is not initialized to expected value with Qt 6.5.3. It works as expected with Qt 5.15.15.

      import QtQuick 2.15
      import QtQuick.Window 2.15
      
      Window {
          width: 640
          height: 480
          visible: true
          title: qsTr("Test initializing through alias to bound bindable property")
      
          component TestComponent: Item {
              id: root
      
              property alias aliasToChildObjectName: child.objectName
      
              Rectangle {
                  id: child
                  objectName: root.objectName + " default"
                  width: 100; height: 100
                  color: objectName === "expected" ? "green" : "red"
                  onObjectNameChanged: {
                      print("child - onObjectNameChanged", child.objectName)
                  }
              }
          }
      
          TestComponent {
              objectName: "root"
              aliasToChildObjectName: "expected"
          }
      }
      


      Output with Qt 5.15.15:

      qml: child - onObjectNameChanged expected

      and a green rectangle.

       

      Output with Qt 6.5.3:

      qml: child - onObjectNameChanged expected
      qml: child - onObjectNameChanged root default

      and a red rectangle.

      The same problem can be reproduced e.g. with Item.x Item.y.

      The problem does not look to occur if:

      • the alias is not directly to the property, e.g. with an alias to the child element and updating the object name with "aliasToChild.objectName = expected"
      • the aliased property is not defined BINDABLE (e.g. with Item.opacity)
      • the aliased property does not have an initial binding, e.g. if in above the child object name would be defined just as "objectName: " default""

      Attachments

        Issue Links

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

          Activity

            People

              mhqanbari MohammadHossein Qanbari
              lasse.lopperi Lasse Lopperi
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes