The QGeoPositionInfoSource class is an abstract base class for the distribution of positional updates. More...
#include <QGeoPositionInfoSource>
Inherits: QObject.
Inherited by: QNmeaPositionInfoSource.
This class was introduced in Qt Mobility 1.0.
enum | PositioningMethod { SatellitePositioningMethods, NonSatellitePositioningMethods, AllPositioningMethods } |
flags | PositioningMethods |
QGeoPositionInfoSource ( QObject * parent ) | |
virtual | ~QGeoPositionInfoSource () |
virtual QGeoPositionInfo | lastKnownPosition ( bool fromSatellitePositioningMethodsOnly = false ) const = 0 |
virtual int | minimumUpdateInterval () const = 0 |
PositioningMethods | preferredPositioningMethods () const |
virtual void | setPreferredPositioningMethods ( PositioningMethods methods ) |
virtual void | setUpdateInterval ( int msec ) |
virtual PositioningMethods | supportedPositioningMethods () const = 0 |
int | updateInterval () const |
virtual void | requestUpdate ( int timeout = 0 ) = 0 |
virtual void | startUpdates () = 0 |
virtual void | stopUpdates () = 0 |
void | positionUpdated ( const QGeoPositionInfo & update ) |
void | updateTimeout () |
QStringList | availableSources () |
QGeoPositionInfoSource * | createDefaultSource ( QObject * parent ) |
QGeoPositionInfoSource * | createSource ( const QString & sourceName, QObject * parent ) |
The QGeoPositionInfoSource class is an abstract base class for the distribution of positional updates.
The static function QGeoPositionInfoSource::createDefaultSource() creates a default position source that is appropriate for the platform, if one is available. Otherwise, QGeoPositionInfoSource will check for available plugins that implement the QGeoPositionInfoSourceFactory interface.
Users of a QGeoPositionInfoSource subclass can request the current position using requestUpdate(), or start and stop regular position updates using startUpdates() and stopUpdates(). When an update is available, positionUpdated() is emitted. The last known position can be accessed with lastKnownPosition().
If regular position updates are required, setUpdateInterval() can be used to specify how often these updates should be emitted. If no interval is specified, updates are simply provided whenever they are available. For example:
// Emit updates every 10 seconds if available QGeoPositionInfoSource *source = QGeoPositionInfoSource::createDefaultSource(0); if (source) source->setUpdateInterval(10000);
To remove an update interval that was previously set, call setUpdateInterval() with a value of 0.
Note that the position source may have a minimum value requirement for update intervals, as returned by minimumUpdateInterval().
Warning: On Windows CE it is not possible to detect if a device is GPS enabled. The default position source on a Windows CE device without GPS support will never provide any position data.
Warning: On Symbian it is currently only possible to instantiate and use the position sources in the main thread of the application.
Defines the types of positioning methods.
Constant | Value | Description |
---|---|---|
QGeoPositionInfoSource::SatellitePositioningMethods | 0x000000ff | Satellite-based positioning methods such as GPS. |
QGeoPositionInfoSource::NonSatellitePositioningMethods | 0xffffff00 | Other positioning methods. |
QGeoPositionInfoSource::AllPositioningMethods | 0xffffffff | A flag that matches all positioning methods. |
The PositioningMethods type is a typedef for QFlags<PositioningMethod>. It stores an OR combination of PositioningMethod values.
This property holds the minimum time (in milliseconds) required to retrieve a position update.
This is the minimum value accepted by setUpdateInterval() and requestUpdate().
This property was introduced in Qt Mobility 1.0.
Access functions:
virtual int | minimumUpdateInterval () const = 0 |
This property holds the requested interval in milliseconds between each update.
If the update interval is not set (or is set to 0) the source will provide updates as often as necessary.
If the update interval is set, the source will provide updates at an interval as close to the requested interval as possible. If the requested interval is less than the minimumUpdateInterval(), the minimum interval is used instead.
Changes to the update interval will happen as soon as is practical, however the time the change takes may vary between implementations. Whether or not the elapsed time from the previous interval is counted as part of the new interval is also implementation dependent.
The default value for this property is 0.
Note: Subclass implementations must call the base implementation of setUpdateInterval() so that updateInterval() returns the correct value.
This property was introduced in Qt Mobility 1.0.
Access functions:
int | updateInterval () const |
virtual void | setUpdateInterval ( int msec ) |
Creates a position source with the specified parent.
Destroys the position source.
Returns a list of available source plugins. Note that this list does not include the default platform backend, if one is available.
Creates and returns a position source with the given parent that reads from the system's default sources of location data, or the plugin with the highest available priority.
Returns 0 if the system has no default position source and no valid plugins could be found.
Note: Symbian applications will need to have the Location capability otherwise this will return 0.
This function was introduced in Qt Mobility 1.0.
Creates and returns a position source with the given parent, by loading the plugin named sourceName.
Returns 0 if the plugin cannot be found.
Returns an update containing the last known position, or a null update if none is available.
If fromSatellitePositioningMethodsOnly is true, this returns the last known position received from a satellite positioning method; if none is available, a null update is returned.
This function was introduced in Qt Mobility 1.0.
If startUpdates() or requestUpdate() is called, this signal is emitted when an update becomes available.
The update value holds the value of the new update.
This function was introduced in Qt Mobility 1.0.
Returns the positioning methods set by setPreferredPositioningMethods().
This function was introduced in Qt Mobility 1.0.
See also setPreferredPositioningMethods().
Attempts to get the current position and emit positionUpdated() with this information. If the current position cannot be found within the given timeout (in milliseconds) or if timeout is less than the value returned by minimumUpdateInterval(), updateTimeout() is emitted.
If the timeout is zero, the timeout defaults to a reasonable timeout period as appropriate for the source.
This does nothing if another update request is in progress. However it can be called even if startUpdates() has already been called and regular updates are in progress.
If the source uses multiple positioning methods, it tries to gets the current position from the most accurate positioning method within the given timeout.
This function was introduced in Qt Mobility 1.0.
Sets the preferred positioning methods for this source to methods.
If methods includes a method that is not supported by the source, the unsupported method will be ignored.
If methods does not include any methods supported by the source, the preferred methods will be set to the set of methods which the source supports.
Note: When reimplementing this method, subclasses must call the base method implementation to ensure preferredPositioningMethods() returns the correct value.
This function was introduced in Qt Mobility 1.0.
See also preferredPositioningMethods() and supportedPositioningMethods().
Starts emitting updates at regular intervals as specified by setUpdateInterval().
If setUpdateInterval() has not been called, the source will emit updates as soon as they become available.
An updateTimout() signal will be emitted if this QGeoPositionInfoSource subclass determines that it will not be able to provide regular updates. This could happen if a satellite fix is lost or if a hardware error is detected. Position updates will recommence if the data becomes available later on. The updateTimout() signal will not be emitted again until after the periodic updates resume.
This function was introduced in Qt Mobility 1.0.
Stops emitting updates at regular intervals.
This function was introduced in Qt Mobility 1.0.
Returns the positioning methods available to this source.
This function was introduced in Qt Mobility 1.0.
See also setPreferredPositioningMethods().
If requestUpdate() was called, this signal will be emitted if the current position could not be retrieved within the specified timeout.
If startUpdates() has been called, this signal will be emitted if this QGeoPositionInfoSource subclass determines that it will not be able to provide further regular updates. This signal will not be emitted again until after the regular updates resume.
This function was introduced in Qt Mobility 1.0.
© 2008-2011 Nokia Corporation and/or its subsidiaries. Nokia, Qt and their respective logos are trademarks of Nokia Corporation in Finland and/or other countries worldwide.
All other trademarks are property of their respective owners. Privacy Policy
Licensees holding valid Qt Commercial licenses may use this document in accordance with the Qt Commercial License Agreement provided with the Software or, alternatively, in accordance with the terms contained in a written agreement between you and Nokia.
Alternatively, this document may be used under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation.