summaryrefslogtreecommitdiffstats
path: root/src/sensors/doc/src/porting.qdoc
blob: 6781174946aadbc71e1ff0e4a2375e9d3b6c7b3c (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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
/****************************************************************************
**
** Copyright (C) 2015 The Qt Company Ltd.
** Contact: http://www.qt.io/licensing/
**
** 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 The Qt Company. For licensing terms
** and conditions see http://www.qt.io/terms-conditions. For further
** information use the contact form at http://www.qt.io/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$
**
****************************************************************************/

/*!
    \page qtsensors-porting.html
    \title Porting Applications from QtMobility Sensors to Qt Sensors
    \brief Explain how to port from QtMobility Sensors to Qt Sensors
    \since Qt 5.1

    \tableofcontents

    \section1 Overview

    The initial release of Qt Sensors (5.0) is generally expected to be source
    compatible with QtMobility Sensors 1.2. This document attempts to explain
    where things need to be changed in order to port applications to Qt Sensors.

    \section1 QML

    In \c QtMobility, the C++ classes like \c QAccelerometer were directly used as QML types.
    In Qt Sensors, there are now separate classes for the QML types, which have no public
    C++ API.

    The new QML types in Qt Sensors fix some issues the former QtMobility QML types had,
    for example:
    \list
    \li The reading types now have proper change notifications.
    \li \c availableDataRates and \c outputRanges of the \c Sensor type are now proper list types.
    \li The \c identifier and \c type properties of \c Sensor can now be used.
    \li The \c lux property of \c LightSensorReading has been renamed to \c illuminance.
    \li The \c QmlSensors singleton now allows to query for sensor types.
    \endlist

    For more information, see the \l {Qt Sensors QML Types}{QML API} documentation.

    \section1 C++

    The C++ API mainly remained the same as in QtMobility.

    \section2 Includes

    QtMobility Sensors installed headers into a \c Qt Sensors directory. This is
    also the directory that Qt Sensors uses. It is therefore expected that includes
    that worked with QtMobility Sensors should continue to work.

    For example:
    \code
    #include <QAccelerometer>
    #include <qaccelerometer.h>
    #include <QtSensors/QAccelerometer>
    #include <QtSensors/qaccelerometer.h>
    \endcode

    \section2 Macros and Namespace

    QtMobility Sensors was built in a \c QtMobility namespace. This was enabled by
    the use of various macros. Qt Sensors does not normally build into a namespace
    and the macros from QtMobility no longer exist.

    \list
    \li QTM_BEGIN_NAMESPACE
    \li QTM_END_NAMESPACE
    \li QTM_USE_NAMESPACE
    \li QTM_PREPEND_NAMESPACE(x)
    \endlist

    Note that Qt can be configured to build into a namespace. If Qt is built in this
    way then Qt Sensors is also built into the nominated namespace. However, as this
    is optional, the macros for this are typically defined to do nothing.

    \list
    \li QT_BEGIN_NAMESPACE
    \li QT_END_NAMESPACE
    \li QT_USE_NAMESPACE
    \li QT_PREPEND_NAMESPACE(x)
    \endlist

    \section2 qtimestamp

    qtimestamp was previously defined as an opaque type equivalent to a quint64. It existed
    as a class due to an implementation detail.

    In Qt Sensors, the API uses quint64 instead of qtimestamp. qtimestamp still exists as a
    typedef so that applications that refer to qtimestamp can be compiled.

    \section1 Project Files

    QtMobility Sensors applications used this in their project files to enable the Sensors API.

    \code
    CONFIG += mobility
    MOBILITY += sensors
    \endcode

    Applications should remove these lines and instead use the following statement to enable
    the Qt Sensors API:

    \code
    QT += sensors
    \endcode
*/