How to make a QQuickItem which will route mouse events to other QuickItem?
-
I do not understand the right approach of QMouseEvent and QTouchEvent forwarding? Because there are PressEvent, MoveEvent and ReleaseEvent types which is not clear how to use when forwarding.
Should I create a new QMouseEvents orignore()
existing to make them propagate? Or What is right approach?Uss case
Goal is to accept mouse events inMapListEventsRouter
which is inherited fromQQuickItem
and forward it to Map or List.
MapListEventsRouter
also controls height ofMap
andList
. Idea is that when scrollingList
down, firstMap
height is decreasing to 0, next the events should go directly toList
.
I have reimplementedvoid mousePressEvent(QMouseEvent* event) override; void mouseReleaseEvent(QMouseEvent* event) override; void mouseMoveEvent(QMouseEvent* event) override;
to achieve desired logic, but
MouseEvent
s do not go toMap
orList
. I have triedevent->ignore()
,QCoreApplication::sendEvent(_list, event)
but with no success. Events just do not propagate toMap
orList
.
What do I do wrong?// simplified code Item { id: root Map { id: aMap height: mapListRouter.mapHeight width: parent.width } ListView { id: aList height: mapListRouter.listHeight width: parent.width } MapListEventsRouter { id: mapListRouter height: parent.height width: parent.width map: aMap list: aList } }