QGeoSatelliteInfoSource Class

The QGeoSatelliteInfoSource class is an abstract base class for the distribution of satellite information updates. 更多...

头: #include <QGeoSatelliteInfoSource>
CMake: find_package(Qt6 REQUIRED COMPONENTS Positioning)
target_link_libraries(mytarget PRIVATE Qt6::Positioning)
qmake: QT += positioning
继承: QObject
继承者:

QNmeaSatelliteInfoSource

公共类型

enum Error { AccessError, ClosedError, NoError, UnknownSourceError, UpdateTimeoutError }

特性

公共函数

virtual ~QGeoSatelliteInfoSource ()
(从 6.2 起) virtual QVariant backendProperty (const QString & name ) const
QBindable<int> bindableUpdateInterval ()
virtual QGeoSatelliteInfoSource::Error error () const = 0
virtual int minimumUpdateInterval () const = 0
(从 6.2 起) virtual bool setBackendProperty (const QString & name , const QVariant & value )
virtual void setUpdateInterval (int msec )
QString sourceName () const
int updateInterval () const

公共槽

virtual void requestUpdate (int timeout = 0) = 0
virtual void startUpdates () = 0
virtual void stopUpdates () = 0

信号

void errorOccurred (QGeoSatelliteInfoSource::Error satelliteError )
void satellitesInUseUpdated (const QList<QGeoSatelliteInfo> & satellites )
void satellitesInViewUpdated (const QList<QGeoSatelliteInfo> & satellites )

静态公共成员

QStringList availableSources ()
QGeoSatelliteInfoSource * createDefaultSource (QObject * parent )
(since Qt 5.14) QGeoSatelliteInfoSource * createDefaultSource (const QVariantMap & 参数 , QObject * parent )
QGeoSatelliteInfoSource * createSource (const QString & sourceName , QObject * parent )
(since Qt 5.14) QGeoSatelliteInfoSource * createSource (const QString & sourceName , const QVariantMap & 参数 , QObject * parent )

详细描述

The static function QGeoSatelliteInfoSource::createDefaultSource () creates a default satellite data source that is appropriate for the platform, if one is available. Otherwise, available QGeoPositionInfoSourceFactory plugins will be checked for one that has a satellite data source available.

调用 startUpdates () 和 stopUpdates () to start and stop regular updates, or requestUpdate () to request a single update. When an update is available, satellitesInViewUpdated () 和/或 satellitesInUseUpdated () 会被发射。

If regular satellite 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
QGeoSatelliteInfoSource *source = QGeoSatelliteInfoSource::createDefaultSource(0);
if (source)
    source->setUpdateInterval(10000);
					

To remove an update interval that was previously set, call setUpdateInterval () with a value of 0.

注意: The satellite source may have a minimum value requirement for update intervals, as returned by minimumUpdateInterval ().

注意: To use this class from Android service, see Qt Positioning 在 Android .

成员类型文档编制

enum QGeoSatelliteInfoSource:: Error

The Error enumeration represents the errors which can occur.

常量 描述
QGeoSatelliteInfoSource::AccessError 0 The connection setup to the satellite backend failed because the application lacked the required privileges.
QGeoSatelliteInfoSource::ClosedError 1 The satellite backend closed the connection, which happens for example in case the user is switching location services to off. This object becomes invalid and should be deleted. A new satellite source can be created by calling createDefaultSource () later on.
QGeoSatelliteInfoSource::NoError 2 没有出现错误。
QGeoSatelliteInfoSource::UnknownSourceError -1 发生无法识别的错误。
QGeoSatelliteInfoSource::UpdateTimeoutError 3 The current satellite information could not be retrieved within the specified timeout.

特性文档编制

[read-only] minimumUpdateInterval : const int

This property holds the minimum time (in milliseconds) required to retrieve a satellite update.

This is the minimum value accepted by setUpdateInterval () 和 requestUpdate ().

访问函数:

virtual int minimumUpdateInterval () const = 0

[bindable] updateInterval : int

注意: 此特性支持 QProperty 绑定。

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.

注意: Subclass implementations must call the base implementation of setUpdateInterval() so that updateInterval() returns the correct value.

成员函数文档编制

[virtual noexcept] QGeoSatelliteInfoSource:: ~QGeoSatelliteInfoSource ()

Destroys the satellite source.

[static] QStringList QGeoSatelliteInfoSource:: availableSources ()

Returns a list of available source plugins, including the default system backend if one is available.

[virtual, since 6.2] QVariant QGeoSatelliteInfoSource:: backendProperty (const QString & name ) const

Returns the value of the backend-specific property named name , if present. Otherwise the returned value will be invalid.

该函数在 Qt 6.2 引入。

另请参阅 setBackendProperty .

[static] QGeoSatelliteInfoSource *QGeoSatelliteInfoSource:: createDefaultSource ( QObject * parent )

Creates and returns a source with the specified parent that reads from the system's default source of satellite update information, or the highest priority available plugin.

返回 nullptr if the system has no default satellite source, no valid plugins could be found or the user does not have the permission to access the satellite data.

[static, since Qt 5.14] QGeoSatelliteInfoSource *QGeoSatelliteInfoSource:: createDefaultSource (const QVariantMap & 参数 , QObject * parent )

Creates and returns a satellite source with the given parent that reads from the system's default sources of satellite data, or the plugin with the highest available priority.

返回 nullptr if the system has no default satellite source, no valid plugins could be found or the user does not have the permission to access the satellite information.

This method passes 参数 to the factory to configure the source.

该函数在 Qt 5.14 引入。

[static] QGeoSatelliteInfoSource *QGeoSatelliteInfoSource:: createSource (const QString & sourceName , QObject * parent )

Creates and returns a source with the given parent , by loading the plugin named sourceName .

返回 nullptr if the plugin cannot be found.

[static, since Qt 5.14] QGeoSatelliteInfoSource *QGeoSatelliteInfoSource:: createSource (const QString & sourceName , const QVariantMap & 参数 , QObject * parent )

Creates and returns a satellite source with the given parent , by loading the plugin named sourceName .

返回 nullptr if the plugin cannot be found.

This method passes 参数 to the factory to configure the source.

该函数在 Qt 5.14 引入。

[pure virtual] QGeoSatelliteInfoSource::Error QGeoSatelliteInfoSource:: error () const

返回最后出现的错误。

注意: Since Qt6 the last error is always reset when calling startUpdates () 或 requestUpdate ().

[signal] void QGeoSatelliteInfoSource:: errorOccurred ( QGeoSatelliteInfoSource::Error satelliteError )

此信号发射,在发生错误后。 satelliteError 参数描述出现错误的类型。

[pure virtual slot] void QGeoSatelliteInfoSource:: requestUpdate ( int timeout = 0)

Attempts to get the current satellite information and emit satellitesInViewUpdated () 和 satellitesInUseUpdated () with this information. If the current satellite information cannot be found within the given timeout (in milliseconds) or if timeout is less than the value returned by minimumUpdateInterval (), an errorOccurred () signal with UpdateTimeoutError 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.

注意: Since Qt6 this method always resets the last error to NoError before requesting the satellite information.

注意: To understand how to use this method from an Android service, see Qt Positioning 在 Android .

[signal] void QGeoSatelliteInfoSource:: satellitesInUseUpdated (const QList < QGeoSatelliteInfo > & satellites )

startUpdates () 或 requestUpdate () is called, this signal is emitted when an update is available on the number of satellites that are currently in use.

These are the satellites that are used to get a "fix" - that is, those used to determine the current position.

The satellites parameter holds the satellites currently in use.

[signal] void QGeoSatelliteInfoSource:: satellitesInViewUpdated (const QList < QGeoSatelliteInfo > & satellites )

startUpdates () 或 requestUpdate () is called, this signal is emitted when an update is available on the satellites that are currently in view.

The satellites parameter holds the satellites currently in view.

[virtual, since 6.2] bool QGeoSatelliteInfoSource:: setBackendProperty (const QString & name , const QVariant & value )

Sets the backend-specific property named name to value 。返回 true 当成功时, false otherwise. Backend-specific properties can be used to configure the satellite info subsystem behavior at runtime.

该函数在 Qt 6.2 引入。

另请参阅 backendProperty .

QString QGeoSatelliteInfoSource:: sourceName () const

Returns the unique name of the satellite source implementation in use.

This is the same name that can be passed to createSource () in order to create a new instance of a particular satellite source implementation.

[pure virtual slot] void QGeoSatelliteInfoSource:: startUpdates ()

Starts emitting updates at regular intervals. The updates will be provided whenever new satellite information becomes available.

If satellite information cannot be retrieved or some other form of timeout has occurred the satellitesInViewUpdated () 和 satellitesInUseUpdated () signals may be emitted with empty parameter lists.

注意: Since Qt6 this method always resets the last error to NoError before starting the updates.

注意: To understand how to use this method from an Android service, see Qt Positioning 在 Android .

另请参阅 satellitesInViewUpdated () 和 satellitesInUseUpdated ().

[pure virtual slot] void QGeoSatelliteInfoSource:: stopUpdates ()

Stops emitting updates at regular intervals.