Qt Sensors - SensorGesture QML Type example

Demonstrates the use of SensorGesture QML type

Demonstrates the use of SensorGesture QML type.


To write a QML application that will use the gesture plugin, following steps are needed:

Import the QtSensors 5.x module:

import QtSensors 5.0

Add the SensorGesture QML type into your qml file.

SensorGesture {
    id: sensorGesture
    enabled: false
    onDetected: {
        if (gesture !== oldGesture)
            count = 0;
        valueText.text = gesture + " " + count;
        oldGesture = gesture;
    onEnabledChanged: {
        valueText.text = ""

Each SensorGesture QML type contains a property called gestures. This example uses an alias gestureId for this property.

property alias gestureId: sensorGesture.gestures

Then, the gesture or gestures to use can be specified using the alias:

onSelectedGestureChanged: {
    gesture.enabled = false;
    gesture.gestureId = gestureList.selectedGesture;

A list of all available gestures is accessible through the availableGestures property:

ListView {
    id: gestureList

    model: gesture.availableGestures

See also

Qt Sensors - ShakeIt QML Example Qt Sensor Gestures

Button.qml Example File

GestureList.qml Example File

GestureView.qml Example File

GesturesView.qml Example File

qmlsensorgestures.qml Example File

qcountergestureplugin.cpp Example File

qcountergestureplugin.h Example File

qcounterrecognizer.cpp Example File

qcounterrecognizer.h Example File

main.cpp Example File

qml.pro Example File

qml.qrc Example File

qmlsensorgestures.pro Example File

plugin.pro Example File