C
PositionSource QML Type
The PositionSource type provides the device's current position. More...
Import Statement: | import QtPositioning |
Since: | Qt Quick Ultralite 2.11 |
Properties
- active : bool
- position : Position
- sourceError : enumeration
- updateInterval : int
- valid : bool
Detailed Description
The PositionSource type provides information about the user device's current position. The position is available as a Position type, which contains some of the standard parameters typically available from GPS and other similar systems, including longitude, latitude, and direction.
The updateInterval property can then be used to indicate how often your application wishes to receive position updates.The active property can be used to control the operation of the PositionSource.
When the PositionSource is active, position updates can be retrieved either by simply using the position property in a binding (as the value of another item's property), or by providing an implementation of the onPositionChanged
signal handler.
Example Usage
The following example shows a simple PositionSource used to receive updates every second and print the longitude and latitude out to the console.
PositionSource { id: src updateInterval: 1000 active: true onPositionChanged: { var coord = src.position.coordinate; console.log("Coordinate:", coord.longitude, coord.latitude); } }
Property Documentation
active : bool
This property indicates whether the position source is active.
position : Position [read-only]
This property holds the last known positional data.
The Position type has different positional member variables, whose validity can be checked with appropriate validity functions.
sourceError : enumeration [read-only]
This property holds the error which last occurred with the PositionSource.
- PositionSource.AccessError - The connection setup to the remote positioning backend failed because the application lacked the required privileges.
- PositionSource.ClosedError - The positioning backend closed the connection, which happens for example in case the user is switching location services to off. As soon as the location service is re-enabled regular updates resume.
- PositionSource.NoError - No error has occurred.
- PositionSource.UnknownSourceError - An unidentified error occurred.
- PositionSource.UpdateTimeoutError - The current position could not be retrieved within the specified timeout, or this PositionSource determined that it's unable to provide further regular updates.
updateInterval : int
This property holds the desired interval between updates (milliseconds).
valid : bool [read-only]
This property is true
if the PositionSource object has acquired a valid Qul::GeoPositionSource to provide data. If it's false
, other methods on the PositionSource have no effect.
Qul::GeoPositionSource must be registered before the initialization of the application root item. For more information, see Qul::GeoPositionSource.
Applications should check this property to determine whether positioning is available on the runtime platform, and react accordingly.
Available under certain Qt licenses.
Find out more.