Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
How can I propagate onPositionChanged() to a child MouseArea?
cscooper last edited by
I've got two overlapping MouseAreas, let's say the big one is at ((0, 0),(100,100)) and the small one is at ((40,40),(50,50)). They both need to get "onPositionChanged" messages.
I can set propagateComposedEvents to true, but positionChanged isn't a composed event (right?) so it doesn't help.
This whole problem might be because the child MouseArea is inside the rowDelegate of a TableView, and all kinds of things get screwy when you have objects inside of Loaders.
What I am trying now, is to subclass MouseArea with ParentMouseArea, changing the big MouseArea to be a ParentMouseArea, and having the small MouseArea register itself with the ParentMouseArea. Then, when ParentMouseArea gets the onPositionChanged(), it can look through its list of child MouseAreas and pass the message on to its children.
This working, except that of course the QQuickMouseEvent being passed to the ParentMouseArea's onPositionChanged() is reporting the mouse coordinates in the ParentMouseArea's coordinate system, and I need to convert them to the child MouseArea's coordinate system before passing them on, and the 'x' and 'y' parameters on QQuickMouseEvent are read-only.
I can call mapToItem() to convert the x and y values to the correct coordinate system, but then I can' do anything useful with the next values.
Is there a way to create a new QQuickMouseEvent with the converted values? Or am I barking up the completely wrong tree?