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

Grouped properties undocumented behavior

    XMLWordPrintable

Details

    Description

      Faced this years ago, reporting now.
      In the following code, in

      onActiveChanged: console.log(active)

      active is resolved as Window::active, not MouseArea::drag::active as one might expect, so this code always prints true.

      import QtQuick 2.6
      import QtQuick.Window 2.2
      
      Window {
          visible: true
          width: 640
          height: 480
      
          Rectangle {
              id: rect
              width: 200
              height: 200
              color: "yellow"
      
              MouseArea {
                  anchors.fill: parent
                  drag {
                      axis: Drag.XAndYAxis
                      target: rect
                      onActiveChanged: console.log(active)
                  }
              }
          }
      }
      

      Most of sub-properties of grouped properties do not have NOTIFY signal, and MouseArea::drag::active is the only example I know, but it is, probably, worth to mention somewhere in docs, that in grouped property's signal handlers, sub-properties should be referenced via dot notation even if signal handler is defined via group notation (http://doc.qt.io/qt-5/qtqml-syntax-objectattributes.html), so the above code could be rewritten as

      import QtQuick 2.6
      import QtQuick.Window 2.2
      
      Window {
          visible: true
          width: 640
          height: 480
      
          Rectangle {
              id: rect
              width: 200
              height: 200
              color: "yellow"
      
              MouseArea {
                  id: mouseArea
                  anchors.fill: parent
                  drag {
                      axis: Drag.XAndYAxis
                      target: rect
                      onActiveChanged: console.log(mouseArea.drag.active)
                  }
              }
          }
      }
      

      Attachments

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

        Activity

          People

            w00t Robin Burchell
            wearyinside Oleg Yadrov
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes