- Qt 5.15
- Qt Quick
- QML Types
- MultiPointTouchArea QML Type
- Qt 5.15.18 Reference Documentation

# MultiPointTouchArea QML Type

Enables handling of multiple touch points. More...

Import Statement: | import QtQuick 2.15
Inherits: | Item

- List of all members, including inherited members

## Properties

- maximumTouchPoints : int
- minimumTouchPoints : int
- mouseEnabled : bool
- touchPoints : list<TouchPoint>

## Signals

- canceled(list<TouchPoint> touchPoints)
- gestureStarted(GestureEvent gesture)
- pressed(list<TouchPoint> touchPoints)
- released(list<TouchPoint> touchPoints)
- touchUpdated(list<TouchPoint> touchPoints)
- updated(list<TouchPoint> touchPoints)

## Detailed Description

A MultiPointTouchArea is an invisible item that is used to track multiple touch points.

The Item::enabled property is used to enable and disable touch handling. When disabled, the touch area becomes transparent to mouse and touch events.

By default, the mouse will be handled the same way as a single touch point, and items under the touch area will not receive mouse events because the touch area is handling them. But if the mouseEnabled property is set to false, it becomes transparent to mouse events so that another mouse-sensitive Item (such as a MouseArea) can be used to handle mouse interaction separately.

MultiPointTouchArea can be used in two ways:

- setting `touchPoints` to provide touch point objects with properties that can be bound to
- using the onTouchUpdated or onPressed, onUpdated and onReleased handlers

While a MultiPointTouchArea can take exclusive ownership of certain touch points, it is also possible to have multiple MultiPointTouchAreas active at the same time, each operating on a different set of touch points.

See also TouchPoint.

## Property Documentation

maximumTouchPoints : int
minimumTouchPoints : int

These properties hold the range of touch points to be handled by the touch area.

These are convenience that allow you to, for example, have nested MultiPointTouchAreas, one handling two finger touches, and another handling three finger touches.

By default, all touch points within the touch area are handled.

If mouseEnabled is true, the mouse acts as a touch point, so it is also subject to these constraints: for example if maximumTouchPoints is two, you can use the mouse as one touch point and a finger as another touch point for a total of two.

mouseEnabled : bool

This property controls whether the MultiPointTouchArea will handle mouse events too. If it is true (the default), the touch area will treat the mouse the same as a single touch point; if it is false, the touch area will ignore mouse events and allow them to "pass through" so that they can be handled by other items underneath.

touchPoints : list<TouchPoint>

This property holds a set of user-defined touch point objects that can be bound to.

If mouseEnabled is true (the default) and the left mouse button is pressed while the mouse is over the touch area, the current mouse position will be one of these touch points.

In the following example, we have two small rectangles that follow our touch points.

     import QtQuick 2.0

     Rectangle {
         width: 400; height: 400
         MultiPointTouchArea {
             anchors.fill: parent
             touchPoints: [
                 TouchPoint { id: point1 },
                 TouchPoint { id: point2 }
             ]
         }

         Rectangle {
             width: 30; height: 30
             color: "green"
             x: point1.x
             y: point1.y
         }

         Rectangle {
             width: 30; height: 30
             color: "yellow"
             x: point2.x
             y: point2.y
         }
     }

By default this property holds an empty list.

See also TouchPoint.

## Signal Documentation

canceled(list<TouchPoint> touchPoints)

This signal is emitted when new touch events have been canceled because another item stole the touch event handling.

This signal is for advanced use: it is useful when there is more than one MultiPointTouchArea that is handling input, or when there is a MultiPointTouchArea inside a Flickable. In the latter case, if you execute some logic in the `onPressed` signal handler and then start dragging, the Flickable may steal the touch handling from the MultiPointTouchArea. In these cases, to reset the logic when the MultiPointTouchArea has lost the touch handling to the Flickable, `canceled` should be handled in addition to released.

touchPoints is the list of canceled points.

Note: The corresponding handler is `onCanceled`.

gestureStarted(GestureEvent gesture)

This signal is emitted when the global drag threshold has been reached.

This signal is typically used when a MultiPointTouchArea has been nested in a Flickable or another MultiPointTouchArea. When the threshold has been reached and the signal is handled, you can determine whether or not the touch area should grab the current touch points. By default they will not be grabbed; to grab them call `gesture.grab()`. If the gesture is not grabbed, the nesting Flickable, for example, would also have an opportunity to grab.

The gesture object also includes information on the current set of `touchPoints` and the `dragThreshold`.

Note: The corresponding handler is `onGestureStarted`.

pressed(list<TouchPoint> touchPoints)

This signal is emitted when new touch points are added. touchPoints is a list of these new points.

If minimumTouchPoints is set to a value greater than one, this signal will not be emitted until the minimum number of required touch points has been reached.

Note: The corresponding handler is `onPressed`.

released(list<TouchPoint> touchPoints)

This signal is emitted when existing touch points are removed. touchPoints is a list of these removed points.

Note: The corresponding handler is `onReleased`.

touchUpdated(list<TouchPoint> touchPoints)

This signal is emitted when the touch points handled by the MultiPointTouchArea change. This includes adding new touch points, removing or canceling previous touch points, as well as updating current touch point data. touchPoints is the list of all current touch points.

Note: The corresponding handler is `onTouchUpdated`.

updated(list<TouchPoint> touchPoints)

This signal is emitted when existing touch points are updated. touchPoints is a list of these updated points.

Note: The corresponding handler is `onUpdated`.