In the very beginning of my QML learning I had a similar problem: I wanted to detect mouse events without interfering with the rest of the application.
It might not be the right solution, maybe it is very bad style or hacky but it works, and might help you.
The idea is to build a C++ item that I use somewhere as parent node to all nodes I want to spy on their mouse events. In this Item
I hook in the childMouseEventFilter
by reimplementing it as follows:
bool MouseEventListener::childMouseEventFilter(QQuickItem *item, QEvent *event)
{
emit mouseEventHappend();
event->ignore(); // Don't know if that is right. I think I should not have it here.
return QQuickItem::childMouseEventFilter(item, event);
}
In this solution I don't check what kind of mouse event I got, but you might, and emit different signals depending on it.
If used on a touch device, there will be two events you might be interested in:
Check the QEvent.type()
to handle them appropriately. The interesting types are:
QEvent::MouseButtonPress
QEvent::MouseButtonRelease
QEvent::MouseMove
QEvent::TouchBegin
QEvent::TouchCancel
QEvent::TouchEnd
QEvent::TouchUpdate
More: http://doc.qt.io/qt-5/qevent.html#Type-enum
Especially the touch events offer nice information about the start of the gesture and the last leg of the finger movement, that might be of interest to you.