/**************************************************************************** ** ** 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 */