PointHandler QML Type

Handler for reacting to a single touchpoint More...

Import Statement: import QtQuick 2.7

Detailed Description

PointHandler can be used to show feedback about a touchpoint or the mouse position, or to otherwise react to pointer events. By being only a passive grabber, it has the ability to keep oversight of all movements, and its grab cannot be stolen even when other gestures are detected and exclusive grabs occur.

If your goal is orthogonal surveillance of eventpoints, an older alternative was QObject::installEventFilter(), but that has never been a built-in QtQuick feature: it requires a custom C++ QQuickItem subclass. PointHandler is more efficient than that, because only pointer events will be delivered to it, during the course of normal event delivery in QQuickWindow, whereas an event filter needs to filter all events of all types, and thus sets itself up as a potential event delivery bottleneck.

One possible use case is to add this handler to a transparent Item which is on top of the rest of the scene, so that when a point is freshly pressed, it will be delivered to that Item and its handlers first, providing the opportunity to take the passive grab as early as possible. Then such an item (like a pane of glass over the whole UI) also becomes a good parent for other Items which visualize the kind of reactive feedback which must always be on top; and likewise it can be the parent for popups, popovers, dialogs and so on. For example, a declared Window can have an Item with a high Z value so that it stays on top. It can also be helpful for your main.cpp to use QQmlContext::setContextProperty() to make the "glass pane" accessible by ID to the entire UI, so that other Items and PointHandlers can be reparented to it.

Inside a PointHandler you can declare a target Item, but PointHandler will not automatically manipulate it in any way. The target Item can bind to properties of the PointHandler. In this way it can follow a point's movements.

See also MultiPointTouchArea.