Qt Sensors - SensorGesture QML Type example


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 and Qt Sensor Gestures.

© 2017 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.