Class: QgsGpsDetector¶
Detects connected GPS device ports.
Class Hierarchy¶
Base classes¶
Methods
Returns the detected GPS connection, and removes it from the detector. |
Static Methods
Signals
Emitted when a GPS connection is successfully detected. |
|
Emitted when the GPS connection has been detected. |
|
Emitted when the detector could not find a valid GPS connection. |
- class qgis.core.QgsGpsDetector[source]¶
Bases:
QObject
- __init__(portName: str | None = '', useUnsafeSignals: bool = True)
Constructor for QgsGpsDetector.
If
portName
is specified, then only devices from the given port will be scanned. Otherwise all connection types will be attempted (including internal GPS devices).Since QGIS 3.38, the
useUnsafeSignals
parameter can be set toFalse
to avoid emitting the dangerous and fragiledetected()
signal. This is highly recommended, but is opt-in to avoid breaking stable QGIS 3.x API. IfuseUnsafeSignals
is set toFalse
, only the safeconnectionDetected()
signal will be emitted and clients must manually take ownership of the detected connection via a call totakeConnection()
.- Parameters:
portName (Optional[str] = '')
useUnsafeSignals (bool = True)
- static availablePorts() List[Tuple[str, str]] ¶
- Return type:
List[Tuple[str, str]]
- signal connectionDetected[source]¶
Emitted when a GPS connection is successfully detected.
Call
takeConnection()
to take ownership of the detected connection.Added in version 3.38.
- signal detected[source]¶
Emitted when the GPS connection has been detected. A single connection must listen for this signal and immediately take ownership of the
connection
object.Deprecated since version 3.40: This signal is dangerous and extremely unsafe! It is recommended to instead set the
useUnsafeSignals
parameter toFalse
in theQgsGpsDetector
constructor and use the safeconnectionDetected()
signal instead.
- takeConnection(self) QgsGpsConnection | None [source]¶
Returns the detected GPS connection, and removes it from the detector.
The caller takes ownership of the connection. Only the first call to this method following a
connectionDetected()
signal will be able to retrieve the detected connection – subsequent calls will returnNone
.Warning
Do not call this method if the useUnsafeSignals option in the
QgsGpsDetector
constructor was set toTrue
.Added in version 3.38.
- Return type:
Optional[QgsGpsConnection]