Details
-
Bug
-
Resolution: Unresolved
-
P4: Low
-
None
-
5.9.0
-
None
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) } } } }