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

Module API signals and property changes cannot be listened using a Connections element

    XMLWordPrintable

Details

    • 6080375fed90c09bfabb96a0319817f14f693b05

    Description

      Connections element doesn't work with objects that are exposed through the new module API. Connections element is handy when you need to listen to a signal of an object that is either exposed as a context property or that hasn't been declared inside the QML document listening to the signal. There might be a good reason why this doesn't work, but nevertheless it goes against developer's expectations.

      Code below

      import QtQuick 2.0
      import module 1.0 as Module
      Connections {
          target: Module
          onPropertyNameChanged: console.log("propertyName", propertyName)
      }
      

      just produces warning

      file:///../file.qml:4: Unable to assign null to QObject*
      

      There exists a simple workaround for listening to property change signals, but this doesn't work with plain signals:

      property variant propertyName: Module.propertyName
      onPropertyNameChanged: console.log("propertyName", propertyName)
      

      Attachments

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

        Activity

          People

            chriadam Christopher Adams (closed Nokia identity) (Inactive)
            jpetrell Joona Petrell
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes