summaryrefslogtreecommitdiffstats
path: root/examples/sensors/sensor_explorer/doc/src/sensor_explorer.qdoc
blob: b40bf39f463c0968983cc68e8ccf22064992760f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
/****************************************************************************
**
** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies).
** Contact: http://www.qt-project.org/legal
**
** This file is part of the documentation of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:FDL$
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia.  For licensing terms and
** conditions see http://qt.digia.com/licensing.  For further information
** use the contact form at http://qt.digia.com/contact-us.
**
** GNU Free Documentation License Usage
** Alternatively, this file may be used under the terms of the GNU Free
** Documentation License version 1.3 as published by the Free Software
** Foundation and appearing in the file included in the packaging of
** this file.  Please review the following information to ensure
** the GNU Free Documentation License version 1.3 requirements
** will be met: http://www.gnu.org/copyleft/fdl.html.
** $QT_END_LICENSE$
**
****************************************************************************/

/*!
    \example sensor_explorer
    \title Qt Sensors - Explorer QML Example
    \ingroup qtsensors-examples
    \brief Demonstrates how to read the meta-data of available sensors.

    \image qtsensors-examples-explorer.png

    This example is divided into two parts:

    \list
    \li A \l{Sensor Explorer QML Import}{C++ plugin} that provides QML
        alternatives for \c QSensorExplorer, \c QPropertyInfo and
        \c QSensorItem C++ classes.
    \li A \l{Sensor Explorer QML Application}{QML Application} that uses
        the QML types to read the sensor meta-data and present it.
    \endlist

    This example is built as an executable with C++ code that runs the QML,
    but it can also be launched directly using the \c qmlscene tool. You
    should build the top-level \e sensor_explorer project before trying to
    run this example or it will not be able to find its dependencies.

    \code
    qmlscene -I . sensor_explorer.qml
    \endcode

    Above, the -I . parameter adds the current directory as a module import
    path to locate the Explorer QML module.

    \section1 Sensor Explorer QML Import

    The Sensor Explorer QML import defines the \e Explorer QML module,
    exporting \c QSensorExplorer, \c QPropertyInfo and \c QSensorItem C++
    classes as QML types. The source code is available in the
    \c sensor_explorer/import subdirectory.

    \section1 Sensor Explorer QML Application

    To write a QML application that will use the QML types exposed by the
    Explorer module, following steps are needed:

    Import the Explorer 1.0 declarative plugin:

    \snippet sensor_explorer/sensor_explorer.qml 0

    Create a SensorExplorer QML item:

    \snippet sensor_explorer/sensor_explorer.qml 1

    You can retrieve a list of all available sensors using
    \c SensorExplorer.availableSensors:

    \snippet sensor_explorer/sensor_explorer.qml 2

    The example uses the returned list as a model to populate a view of
    available sensors.

    To retrieve the properties of a sensor, use \c SensorItem.properties:

    \snippet sensor_explorer/sensor_explorer.qml 3

    The property list is used as a model for another view that displays the
    property names and values.

    It is possible to edit the values of certain sensor properties. Selecting
    a writable property value will open an editor. \c SensorExplorer QML
    type allows you to pass a new value for a sensor property value as
    follows:

    \snippet sensor_explorer/sensor_explorer.qml 4

    Starting and stopping a sensor can be done by setting the
    \c SensorItem.start property:

    \snippet sensor_explorer/sensor_explorer.qml 5
*/