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

Can't using an attached property to target in Connections

    XMLWordPrintable

Details

    • 9f089022bec116b1a7ae415c431768d5b6a67a8a 1243279ddc92bab67bc75e4ecb4ce793715ed11f

    Description

      import QtQuick.Window 2.15
      import QtQuick 2.15
      
      Window {
          width: 640
          height: 480
          visible: true
          title: qsTr("Hello World")
      
          Item {
              id: item
          }
      
          Connections {
              target: item.Window
              function onWindowChanged() {
                  console.log("window changed of item")
              }
      
              Component.onCompleted: {
                  console.log(target, item.Window)
                  console.assert(target !== item, "Target is the item self, and is not its attached object.")
              }
          }
      }
      
      

      In the Qt 5.15.8, I get the follow logs:

      Qt 5.15.8

      QML debugging is enabled. Only use this in a safe environment.
      qml: QQuickItem(0x5633eba9ec20) QQuickWindowAttached(0x5633eb860190)
      Target is the item self, and is not its attached object.
      onCompleted (qrc:/qml_attached_properties_bug/main.qml:22)

      In the Qt 6.4.2, I get the follow logs:

      Qt 6.4.2

      QML debugging is enabled. Only use this in a safe environment.
      qml: QQuickWindowAttached(0x56135bbdf2e0) QQuickWindowAttached(0x56135bbdf2e0)

      So, Is it a known bug?

      Attachments

        Issue Links

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

          Activity

            People

              qtqmlteam Qt Qml Team User
              zccrs JiDe Zhang
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes