Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qt6-changes.qdoc
Go to the documentation of this file.
1// Copyright (C) 2021 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
3
4/*!
5 \page qtpositioning-changes-qt6.html
6 \title Changes to Qt Positioning
7 \ingroup changes-qt-5-to-6
8 \brief Migrate Qt Positioning to Qt 6.
9
10 Qt 6 is a result of the conscious effort to make the framework more
11 efficient and easy to use.
12
13 We try to maintain binary and source compatibility for all the public
14 APIs in each release. But some changes were inevitable in an effort to
15 make Qt a better framework.
16
17 In this topic we summarize those changes in Qt Positioning, and provide
18 guidance to handle them.
19
20 \section1 Breaking public API changes
21
22 This section contains information about API changes that break source
23 compatibility.
24
25 \section2 Rename QGeoPolygon::path()
26
27 The \c QGeoPolygon::path() and \c QGeoPolygon::setPath() methods are renamed
28 to \l QGeoPolygon::perimeter() and \l QGeoPolygon::setPerimeter()
29 respectively. On the QML side the \l QGeoPolygon::perimeter property can be
30 used without any changes.
31
32 \section2 Use \l QGeoShape for \l QGeoLocation bounding area
33
34 The \l QGeoLocation class and its \l [QML] Location QML counterpart are
35 updated to use \l QGeoShape instead of \l QGeoRectangle for a bounding area.
36
37 \section3 C++
38
39 The \c QGeoLocation::boundingBox() and \c QGeoLocation::setBoundingBox()
40 are replaced by \l QGeoLocation::boundingShape() and
41 \l QGeoLocation::setBoundingShape() respectively. A \l QGeoShape object
42 is now used as an underlying data storage.
43
44 \section3 QML
45
46 The \c QGeoLocation::boundingBox property is replaced by
47 \l QGeoLocation::boundingShape. This property is available since
48 QtPositioning 6.2, so make sure to update the import version in the QML
49 files.
50
51 \code
52 import QtPositioning 6.2
53 \endcode
54
55 \section2 Remove QGeoShape::extendShape()
56
57 The \c QGeoShape::extendShape() method was deprecated in Qt 5.9 and finally
58 removed in Qt 6. Use \l QGeoRectangle::extendRectangle() and
59 \l QGeoCircle::extendCircle() if you need this functionality for these
60 classes.
61
62 \section2 Rename signal error to errorOccurred
63
64 In Qt 5 multiple Qt Positioning classes had the \c error() signal, which was
65 clashing with the \c error() method. In Qt 6 we renamed these signals to
66 \c errorOccurred(). Specifically:
67
68 \list
69
70 \li \c QGeoAreaMonitorSource::error() is renamed to
71 \l QGeoAreaMonitorSource::errorOccurred().
72
73 \li \c QGeoPositionInfoSource::error() is renamed to
74 \l QGeoPositionInfoSource::errorOccurred().
75
76 \li \c QGeoSatelliteInfoSource::error() is renamed to
77 \l QGeoSatelliteInfoSource::errorOccurred().
78
79 \endlist
80
81 \section2 Remove update timeout signals
82
83 In Qt 5 \c {QGeoPositionInfoSource::updateTimeout()} and
84 \c {QGeoSatelliteInfoSource::requestTimeout()} signals were used to notify
85 about the cases when the current position or satellite information could
86 not be retrieved within specified timeout. These signals were removed in
87 Qt 6. The \c {errorOccurred()} signals with the new error types are
88 used instead. Specifically:
89
90 \list
91
92 \li \l QGeoPositionInfoSource uses an \l {QGeoPositionInfoSource::}
93 {errorOccurred()} signal with a new
94 \l QGeoPositionInfoSource::UpdateTimeoutError error code.
95
96 \li \l QGeoSatelliteInfoSource uses an \l {QGeoSatelliteInfoSource::}
97 {errorOccurred()} signal with a new
98 \l QGeoSatelliteInfoSource::UpdateTimeoutError error code.
99
100 \endlist
101
102 Same changes apply to \l [QML] PositionSource QML object. The
103 \c {PositionSource::updateTimeout()} signal is removed.
104 \l [QML] {PositionSource::sourceError} property with a
105 \c {PositionSource.UpdateTimeoutError} is used instead.
106
107 \section2 Redesign NMEA support
108
109 In Qt 5 we had a \b serialnmea positioning plugin and a \c nmeaSource
110 property in \l [QML] {PositionSource} object.
111
112 The plugin provided access to NMEA streams via serial port, while the QML
113 object was responsible for reading NMEA stream from TCP socket or local
114 file.
115
116 In Qt 6 we joined all these features in the plugin, which is now renamed to
117 \b nmea. It is now capable of working with all three NMEA data sources:
118 serial port, TCP socket and local file. See \l {Qt Positioning NMEA plugin}
119 {plugin description} for more details.
120
121 The \c nmeaSource property of \l [QML] {PositionSource} object is now
122 removed.
123
124 \section1 Other API changes
125
126 This section contains API improvements that do not break source
127 compatibility. However they might have an impact on the application logic,
128 so it is still useful to know about them.
129
130 \section2 Reset errors properly
131
132 In Qt 5 the errors for \l QGeoAreaMonitorSource, \l QGeoPositionInfoSource
133 and \l QGeoSatelliteInfoSource classes were never reset. This behavior is
134 not logical, as calling \c {startUpdates()}, \c {startMonitoring()} or
135 \c {requestUpdates()} on one of these classes or their subclasses
136 effectively means starting a new work sessions, which means that we should
137 not care about previous errors. Since Qt 6 we reset the error to \c NoError
138 once one of the aforementioned methods is called.
139
140 \section2 Add \l QGeoAddress::streetNumber
141
142 The \l QGeoAddress class is extended with \l {QGeoAddress::}{streetNumber}
143 property, which holds the information about street number, building name, or
144 anything else that might be used to distinguish one address from another.
145 Use \l {QGeoAddress::}{streetNumber()} and \l {QGeoAddress::}
146 {setStreetNumber()} to access this property from C++ code.
147
148 The \l QGeoAddress::street now holds only the street name.
149
150 Same applies to \l [QML] {Address} QML counterpart. The \l [QML]
151 {Address::street} property is now used only for street name, while the
152 \l [QML] {Address::streetNumber} property is used for other important
153 address details.
154
155 \section2 Add timeout argument to \l [QML] {PositionSource::update()}
156
157 The \c timeout is specified in milliseconds. If the \c timeout is zero
158 (the default value), it defaults to a reasonable timeout period as
159 appropriate for the source.
160
161 \section2 Refactor \l QGeoSatelliteInfo, \l QGeoPositionInfo and \l QGeoAreaMonitorInfo classes
162
163 These classes now use \l QExplicitlySharedDataPointer in their
164 implementation. It means that the classes implement copy-on-write. It makes
165 them cheap to copy, so that they can be passed by value.
166
167 Another improvement is the addition of support for the efficient move
168 operations.
169
170 \section1 Changes in Qt Positioning plugin implementation
171
172 This section provides information about the changes in plugin interface.
173
174 In Qt 5 for we had two versions of plugin interface:
175
176 \list
177
178 \li \c QGeoPositionInfoSourceFactory which provided the basic features.
179 \li \c QGeoPositionInfoSourceFactoryV2 which extended the base class with
180 the possibility to provide custom parameters for the created objects.
181
182 \endlist
183
184 In Qt 6 we merged these two implementations into one, leaving only the
185 \l QGeoPositionInfoSourceFactory class. Its methods now allow to pass
186 custom parameters.
187
188 \note The interface \e identifier is updated to reflect the major version
189 update. Use \c {"org.qt-project.qt.position.sourcefactory/6.0"} in your
190 Qt Positioning plugins.
191
192 Here is an example of plugin class declaration:
193
194 \code
195 class MyPlugin : public QObject, public QGeoPositionInfoSourceFactory
196 {
197 Q_OBJECT
198 Q_PLUGIN_METADATA(IID "org.qt-project.qt.position.sourcefactory/6.0"
199 FILE "plugin.json")
200 Q_INTERFACES(QGeoPositionInfoSourceFactory)
201
202 public:
203 QGeoPositionInfoSource *positionInfoSource(QObject *parent, const QVariantMap &parameters) override;
204 QGeoSatelliteInfoSource *satelliteInfoSource(QObject *parent, const QVariantMap &parameters) override;
205 QGeoAreaMonitorSource *areaMonitor(QObject *parent, const QVariantMap &parameters) override;
206 };
207 \endcode
208
209*/