QGeoPositionInfoSourceclass is an abstract base class for the distribution of positional updates. 更多 …
def
backendProperty
(name)
def
preferredPositioningMethods
()
def
setBackendProperty
(name, value)
def
sourceName
()
def
updateInterval
()
def
error
()
def
lastKnownPosition
([fromSatellitePositioningMethodsOnly=false])
def
minimumUpdateInterval
()
def
requestUpdate
([timeout=0])
def
setPreferredPositioningMethods
(methods)
def
setUpdateInterval
(msec)
def
startUpdates
()
def
stopUpdates
()
def
supportedPositioningMethods
()
def
error
(arg__1)
def
positionUpdated
(update)
def
updateTimeout
()
def
availableSources
()
def
createDefaultSource
(parameters, parent)
def
createDefaultSource
(parent)
def
createSource
(sourceName, parameters, parent)
def
createSource
(sourceName, parent)
The static function
createDefaultSource()creates a default position source that is appropriate for the platform, if one is available. Otherwise,QGeoPositionInfoSourcewill check for available plugins that implement theQGeoPositionInfoSourceFactory接口。Users of a
QGeoPositionInfoSourcesubclass can request the current position usingrequestUpdate(), or start and stop regular position updates usingstartUpdates()andstopUpdates(). When an update is available,positionUpdated()is emitted. The last known position can be accessed withlastKnownPosition().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().
QGeoPositionInfoSource
(
parent
)
¶
- param parent
QObject
Creates a position source with the specified
parent
.
PySide2.QtPositioning.QGeoPositionInfoSource.
Error
¶
The Error enumeration represents the errors which can occur.
|
常量 |
描述 |
|---|---|
|
QGeoPositionInfoSource.AccessError |
The connection setup to the remote positioning backend failed because the application lacked the required privileges. |
|
QGeoPositionInfoSource.ClosedError |
The remote 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 will resume. |
|
QGeoPositionInfoSource.NoError |
没有发生错误。 |
|
QGeoPositionInfoSource.UnknownSourceError |
发生无法识别的错误。 |
PySide2.QtPositioning.QGeoPositionInfoSource.
PositioningMethod
¶
Defines the types of positioning methods.
|
常量 |
描述 |
|---|---|
|
QGeoPositionInfoSource.NoPositioningMethods |
None of the positioning methods. |
|
QGeoPositionInfoSource.SatellitePositioningMethods |
Satellite-based positioning methods such as GPS or GLONASS. |
|
QGeoPositionInfoSource.NonSatellitePositioningMethods |
Other positioning methods such as 3GPP cell identifier or WiFi based positioning. |
|
QGeoPositionInfoSource.AllPositioningMethods |
Satellite-based positioning methods as soon as available. Otherwise non-satellite based methods. |
PySide2.QtPositioning.QGeoPositionInfoSource.
availableSources
(
)
¶
字符串列表
Returns a list of available source plugins. This includes any default backend plugin for the current platform.
PySide2.QtPositioning.QGeoPositionInfoSource.
backendProperty
(
name
)
¶
name – unicode
object
Returns the value of the backend-specific property named
name
, if present. Otherwise, the returned value will be invalid. Supported backend-specific properties are listed and described in
Qt Positioning plugins#Default plugins
.
另请参阅
PySide2.QtPositioning.QGeoPositionInfoSource.
createDefaultSource
(
parent
)
¶
parent
–
QObject
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, no valid plugins could be found or the user does not have the permission to access the current position.
PySide2.QtPositioning.QGeoPositionInfoSource.
createDefaultSource
(
参数
,
parent
)
¶
参数 –
parent
–
QObject
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 nullptr if the system has no default position source, no valid plugins could be found or the user does not have the permission to access the current position.
This method passes
参数
to the factory to configure the source.
PySide2.QtPositioning.QGeoPositionInfoSource.
createSource
(
sourceName
,
parent
)
¶
sourceName – unicode
parent
–
QObject
Creates and returns a position source with the given
parent
, by loading the plugin named
sourceName
.
Returns 0 if the plugin cannot be found.
PySide2.QtPositioning.QGeoPositionInfoSource.
createSource
(
sourceName
,
参数
,
parent
)
¶
sourceName – unicode
参数 –
parent
–
QObject
Creates and returns a position source with the given
parent
, by loading the plugin named
sourceName
.
Returns nullptr if the plugin cannot be found.
This method passes
参数
to the factory to configure the source.
PySide2.QtPositioning.QGeoPositionInfoSource.
lastKnownPosition
(
[
fromSatellitePositioningMethodsOnly=false
]
)
¶
fromSatellitePositioningMethodsOnly
–
bool
Returns an update containing the last known position, or a null update if none is available.
若
fromSatellitePositioningMethodsOnly
is true, this returns the last known position received from a satellite positioning method; if none is available, a null update is returned.
PySide2.QtPositioning.QGeoPositionInfoSource.
minimumUpdateInterval
(
)
¶
int
PySide2.QtPositioning.QGeoPositionInfoSource.
positionUpdated
(
update
)
¶
update
–
QGeoPositionInfo
PySide2.QtPositioning.QGeoPositionInfoSource.
preferredPositioningMethods
(
)
¶
PositioningMethods
Returns the positioning methods set by
setPreferredPositioningMethods()
.
PySide2.QtPositioning.QGeoPositionInfoSource.
requestUpdate
(
[
timeout=0
]
)
¶
timeout
–
int
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 get the current position from the most accurate positioning method within the given timeout.
PySide2.QtPositioning.QGeoPositionInfoSource.
setBackendProperty
(
name
,
value
)
¶
name – unicode
value – object
bool
Sets the backend-specific property named
name
to
value
。返回
true
当成功时,
false
otherwise. Backend-specific properties can be used to configure the positioning subsystem behavior at runtime. Supported backend-specific properties are listed and described in
Qt Positioning plugins#Default plugins
.
另请参阅
PySide2.QtPositioning.QGeoPositionInfoSource.
setPreferredPositioningMethods
(
methods
)
¶
methods
–
PositioningMethods
Sets the preferred positioning methods for this source to
methods
.
若
methods
includes a method that is not supported by the source, the unsupported method will be ignored.
若
methods
does not include a single method available/supported by the source, the preferred methods will be set to the set of methods which the source has available. If the source has no method availabe (e.g. because its Location service is turned off or it does not offer a Location service), the passed
methods
are accepted as they are.
注意
When reimplementing this method, subclasses must call the base method implementation to ensure
preferredPositioningMethods()
returns the correct value.
PySide2.QtPositioning.QGeoPositionInfoSource.
setUpdateInterval
(
msec
)
¶
msec
–
int
另请参阅
PySide2.QtPositioning.QGeoPositionInfoSource.
sourceName
(
)
¶
unicode
PySide2.QtPositioning.QGeoPositionInfoSource.
startUpdates
(
)
¶
Starts emitting updates at regular intervals as specified by
setUpdateInterval()
.
若
setUpdateInterval()
has not been called, the source will emit updates as soon as they become available.
An
updateTimeout()
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
updateTimeout()
signal will not be emitted again until after the periodic updates resume.
On iOS, starting from version 8, Core Location framework requires additional entries in the application’s Info.plist with keys NSLocationAlwaysUsageDescription or NSLocationWhenInUseUsageDescription and a string to be displayed in the authorization prompt. The key NSLocationWhenInUseUsageDescription is used when requesting permission to use location services while the app is in the foreground. The key NSLocationAlwaysUsageDescription is used when requesting permission to use location services whenever the app is running (both the foreground and the background). If both entries are defined, NSLocationWhenInUseUsageDescription has a priority in the foreground mode.
PySide2.QtPositioning.QGeoPositionInfoSource.
stopUpdates
(
)
¶
Stops emitting updates at regular intervals.
PySide2.QtPositioning.QGeoPositionInfoSource.
supportedPositioningMethods
(
)
¶
PositioningMethods
Returns the positioning methods available to this source. Availability is defined as being usable at the time of calling this function. Therefore user settings like turned off location service or limitations to Satellite-based position providers are reflected by this function. Runtime notifications when the status changes can be obtained via
supportedPositioningMethodsChanged()
.
Not all platforms distinguish the different positioning methods or communicate the current user configuration of the device. The following table provides an overview of the current platform situation:
|
平台 |
简要描述 |
|
Android |
Individual provider status and general Location service state are known and communicated when location service is active. |
|
GeoClue |
Hardcoced to always return
|
|
GeoClue2 |
Individual providers are not distinguishable but disabled Location services reflected. |
|
iOS/tvOS |
Hardcoced to always return
|
|
macOS |
Hardcoced to always return
|
|
Windows (UWP) |
Individual providers are not distinguishable but disabled Location services reflected. |
PySide2.QtPositioning.QGeoPositionInfoSource.
supportedPositioningMethodsChanged
(
)
¶
PySide2.QtPositioning.QGeoPositionInfoSource.
updateInterval
(
)
¶
int
另请参阅
PySide2.QtPositioning.QGeoPositionInfoSource.
updateTimeout
(
)
¶