'how to bind to `MouseArea`'s `onDragChanged`?
Qt Creator suggests that the onDragChanged slot exists in MouseArea.
MouseArea {
id: mouseArea
...
onDragChanged: console.log('Drag changed')
}
But at runtime it fails with:
Cannot assign to non-existent property "onDragChanged"
Solution 1:[1]
The proper way would be:
drag.onActiveChanged: console.log("Drag active:", drag.active)
This is because drag is a group of properties (under the hood it's a QObject or alike), so you need to reference that group first.
Your initial attempt doesn't work because drag is declared as CONSTANT Q_PROPERTY, which doesn't have a on...Changed signal
Solution 2:[2]
Silly workaround (but it works...)
readonly property bool _dragActive: drag.active
on_DragActiveChanged: {
... = drag.active
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Amfasis |
| Solution 2 | fferri |
