QGeoAreaMonitorSource

The QGeoAreaMonitorSource class enables the detection of proximity changes for a specified set of coordinates. More

Inheritance diagram of PySide6.QtPositioning.QGeoAreaMonitorSource

Synopsis

Functions

Virtual functions

Static functions

Detailed Description

A QGeoAreaMonitorSource emits signals when the current position is in range, or has moved out of range, of a specified area. Each area is specified by a QGeoAreaMonitorInfo object. For example:

public:
    MyClass() : QObject()
    {
        QGeoAreaMonitorSource *monitor = QGeoAreaMonitorSource::createDefaultSource(this);
        if (monitor) {
            connect(monitor, SIGNAL(areaEntered(QGeoAreaMonitorInfo,QGeoPositionInfo)),
                    this, SLOT(areaEntered(QGeoAreaMonitorInfo,QGeoPositionInfo)));
            connect(monitor, SIGNAL(areaExited(QGeoAreaMonitorInfo,QGeoPositionInfo)),
                    this, SLOT(areaExited(QGeoAreaMonitorInfo,QGeoPositionInfo)));

            QGeoAreaMonitorInfo bigBen("Big Ben");
            QGeoCoordinate position(51.50104, -0.124632);
            bigBen.setArea(QGeoCircle(position, 100));

            monitor->startMonitoring(bigBen);

        } else {
            qDebug() << "Could not create default area monitor";
        }
    }

public Q_SLOTS:
    void areaEntered(const QGeoAreaMonitorInfo &mon, const QGeoPositionInfo &update)
    {
        Q_UNUSED(mon);

        qDebug() << "Now within 100 meters, current position is" << update.coordinate();
    }

    void areaExited(const QGeoAreaMonitorInfo &mon, const QGeoPositionInfo &update)
    {
        Q_UNUSED(mon);

        qDebug() << "No longer within 100 meters, current position is" << update.coordinate();
    }

QGeoAreaMonitorSource follows a singleton pattern. Each instance of the class with the same sourceName() shares the same area monitoring backend. If a new QGeoAreaMonitorInfo object is added via startMonitoring() or requestUpdate() it can be retrieved by another instance of this class (provided that they are sourced from the same area monitor provider plug-in). The same singleton pattern applies to the QGeoPositionInfoSource instance used by this class. The following code snippet emphasizes the behavior:

QGeoAreaMonitorSource *s1 = QGeoAreaMonitorSource::createSource("blah", this);
QGeoAreaMonitorSource *s2 = QGeoAreaMonitorSource::createSource("blah", this);
QVERIFY(s1->positionInfoSource() == s2->positionInfoSource);
class PySide6.QtPositioning.QGeoAreaMonitorSource(parent)
Parameters

parentPySide6.QtCore.QObject

Creates a monitor source with the given parent.

PySide6.QtPositioning.QGeoAreaMonitorSource.Error

Defines the types of positioning methods.

The Error enumeration represents the errors which can occur.

Constant

Description

QGeoAreaMonitorSource.AccessError

The connection setup to the remote area monitoring backend failed because the application lacked the required privileges.

QGeoAreaMonitorSource.InsufficientPositionInfo

The area monitoring source could not retrieve a location fix or the accuracy of the fix is not high enough to provide an effective area monitoring.

QGeoAreaMonitorSource.NoError

No error has occurred.

QGeoAreaMonitorSource.UnknownSourceError

An unidentified error occurred.

PySide6.QtPositioning.QGeoAreaMonitorSource.AreaMonitorFeature

Defines the types of area monitoring capabilities.

Constant

Description

QGeoAreaMonitorSource.PersistentAreaMonitorFeature

QGeoAreaMonitorInfo instances can be made persistent. A persistent monitor continues to be active even when the application managing the monitor is not running.

QGeoAreaMonitorSource.AnyAreaMonitorFeature

Matches all possible area monitoring features.

PySide6.QtPositioning.QGeoAreaMonitorSource.activeMonitors()
Return type

PySide6.QtPositioning.QGeoAreaMonitorSource.activeMonitors(lookupArea)
Parameters

lookupAreaPySide6.QtPositioning.QGeoShape

Return type

PySide6.QtPositioning.QGeoAreaMonitorSource.areaEntered(monitor, update)
Parameters
PySide6.QtPositioning.QGeoAreaMonitorSource.areaExited(monitor, update)
Parameters
static PySide6.QtPositioning.QGeoAreaMonitorSource.availableSources()
Return type

list of strings

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

PySide6.QtPositioning.QGeoAreaMonitorSource.backendProperty(name)
Parameters

name – str

Return type

object

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

static PySide6.QtPositioning.QGeoAreaMonitorSource.createDefaultSource(parent)
Parameters

parentPySide6.QtCore.QObject

Return type

PySide6.QtPositioning.QGeoAreaMonitorSource

Creates and returns a monitor source with the given parent that monitors areas using resources on the underlying system.

Returns nullptr if the system has no support for position monitoring.

static PySide6.QtPositioning.QGeoAreaMonitorSource.createSource(sourceName, parent)
Parameters
Return type

PySide6.QtPositioning.QGeoAreaMonitorSource

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

Returns nullptr if the plugin cannot be found.

PySide6.QtPositioning.QGeoAreaMonitorSource.error()
Return type

Error

PySide6.QtPositioning.QGeoAreaMonitorSource.errorOccurred(error)
Parameters

errorError

PySide6.QtPositioning.QGeoAreaMonitorSource.monitorExpired(monitor)
Parameters

monitorPySide6.QtPositioning.QGeoAreaMonitorInfo

PySide6.QtPositioning.QGeoAreaMonitorSource.positionInfoSource()
Return type

PySide6.QtPositioning.QGeoPositionInfoSource

Returns the current QGeoPositionInfoSource used by this QGeoAreaMonitorSource object. The function will return createDefaultSource() if no other object has been set.

The function returns nullptr if not even a default QGeoPositionInfoSource exists.

Any usage of the returned QGeoPositionInfoSource instance should account for the fact that it may reside in a different thread.

PySide6.QtPositioning.QGeoAreaMonitorSource.requestUpdate(monitor, signal)
Parameters
Return type

bool

PySide6.QtPositioning.QGeoAreaMonitorSource.setBackendProperty(name, value)
Parameters
  • name – str

  • value – object

Return type

bool

Sets the backend-specific property named name to value. Returns true on success, otherwise returns false. Backend-specific properties can be used to configure the area monitoring subsystem behavior at runtime.

PySide6.QtPositioning.QGeoAreaMonitorSource.setPositionInfoSource(source)
Parameters

sourcePySide6.QtPositioning.QGeoPositionInfoSource

Sets the new QGeoPositionInfoSource to be used by this QGeoAreaMonitorSource object. The area monitoring backend becomes the new QObject parent for newSource. The previous QGeoPositionInfoSource object will be deleted. All QGeoAreaMonitorSource instances based on the same sourceName() share the same QGeoPositionInfoSource instance.

This may be useful when it is desirable to manipulate the positioning system used by the area monitoring engine.

Note that ownership must be taken care of by subclasses of QGeoAreaMonitorSource . Due to the singleton pattern behind this class newSource may be moved to a new thread.

PySide6.QtPositioning.QGeoAreaMonitorSource.sourceName()
Return type

str

Returns the unique name of the area monitor 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 area monitor source implementation.

PySide6.QtPositioning.QGeoAreaMonitorSource.startMonitoring(monitor)
Parameters

monitorPySide6.QtPositioning.QGeoAreaMonitorInfo

Return type

bool

PySide6.QtPositioning.QGeoAreaMonitorSource.stopMonitoring(monitor)
Parameters

monitorPySide6.QtPositioning.QGeoAreaMonitorInfo

Return type

bool

PySide6.QtPositioning.QGeoAreaMonitorSource.supportedAreaMonitorFeatures()
Return type

AreaMonitorFeatures