Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
QGeoAreaMonitorSource Class Referenceabstract

\inmodule QtPositioning More...

#include <qgeoareamonitorsource.h>

+ Inheritance diagram for QGeoAreaMonitorSource:
+ Collaboration diagram for QGeoAreaMonitorSource:

Public Types

enum  Error { AccessError = 0 , InsufficientPositionInfo = 1 , UnknownSourceError = 2 , NoError = 3 }
 Defines the types of positioning methods. More...
 
enum  AreaMonitorFeature { PersistentAreaMonitorFeature = 0x00000001 , AnyAreaMonitorFeature = 0xffffffff }
 Defines the types of area monitoring capabilities. More...
 

Signals

void areaEntered (const QGeoAreaMonitorInfo &monitor, const QGeoPositionInfo &update)
 Emitted when the current position has moved from a position outside of the active monitor to a position within the monitored area.
 
void areaExited (const QGeoAreaMonitorInfo &monitor, const QGeoPositionInfo &update)
 Emitted when the current position has moved from a position within the active monitor to a position outside the monitored area.
 
void monitorExpired (const QGeoAreaMonitorInfo &monitor)
 Emitted when monitor has expired.
 
void errorOccurred (QGeoAreaMonitorSource::Error error)
 This signal is emitted after an error occurred.
 
- Signals inherited from QObject
void destroyed (QObject *=nullptr)
 This signal is emitted immediately before the object obj is destroyed, after any instances of QPointer have been notified, and cannot be blocked.
 
void objectNameChanged (const QString &objectName, QPrivateSignal)
 This signal is emitted after the object's name has been changed.
 

Public Member Functions

 QGeoAreaMonitorSource (QObject *parent)
 Creates a monitor source with the given parent.
 
virtual ~QGeoAreaMonitorSource ()
 Destroys the monitor source.
 
virtual void setPositionInfoSource (QGeoPositionInfoSource *source)
 Sets the new \l QGeoPositionInfoSource to be used by this QGeoAreaMonitorSource object.
 
virtual QGeoPositionInfoSourcepositionInfoSource () const
 Returns the current QGeoPositionInfoSource used by this QGeoAreaMonitorSource object.
 
QString sourceName () const
 Returns the unique name of the area monitor source implementation in use.
 
virtual Error error () const =0
 Returns the type of error that last occurred.
 
virtual AreaMonitorFeatures supportedAreaMonitorFeatures () const =0
 Returns the area monitoring features available to this source.
 
virtual bool startMonitoring (const QGeoAreaMonitorInfo &monitor)=0
 Returns true if the monitoring of monitor could be successfully started; otherwise returns false.
 
virtual bool stopMonitoring (const QGeoAreaMonitorInfo &monitor)=0
 Returns true if monitor was successfully removed from the list of \l activeMonitors(); otherwise returns false.
 
virtual bool requestUpdate (const QGeoAreaMonitorInfo &monitor, const char *signal)=0
 Enables single shot area monitoring.
 
virtual QList< QGeoAreaMonitorInfoactiveMonitors () const =0
 Returns the list of all active monitors known to the QGeoAreaMonitorSource object.
 
virtual QList< QGeoAreaMonitorInfoactiveMonitors (const QGeoShape &lookupArea) const =0
 Returns the list of all active monitors known to the QGeoAreaMonitorSource object whose center lies within lookupArea.
 
virtual bool setBackendProperty (const QString &name, const QVariant &value)
 
virtual QVariant backendProperty (const QString &name) const
 
- Public Member Functions inherited from QObject
Q_INVOKABLE QObject (QObject *parent=nullptr)
 Constructs an object with parent object parent.
 
virtual ~QObject ()
 Destroys the object, deleting all its child objects.
 
virtual bool event (QEvent *event)
 This virtual function receives events to an object and should return true if the event e was recognized and processed.
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 Filters events if this object has been installed as an event filter for the watched object.
 
QString objectName () const
 
Q_WEAK_OVERLOAD void setObjectName (const QString &name)
 Sets the object's name to name.
 
void setObjectName (QAnyStringView name)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
QBindable< QStringbindableObjectName ()
 
bool isWidgetType () const
 Returns true if the object is a widget; otherwise returns false.
 
bool isWindowType () const
 Returns true if the object is a window; otherwise returns false.
 
bool isQuickItemType () const
 Returns true if the object is a QQuickItem; otherwise returns false.
 
bool signalsBlocked () const noexcept
 Returns true if signals are blocked; otherwise returns false.
 
bool blockSignals (bool b) noexcept
 If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke anything connected to it).
 
QThreadthread () const
 Returns the thread in which the object lives.
 
bool moveToThread (QThread *thread QT6_DECL_NEW_OVERLOAD_TAIL)
 Changes the thread affinity for this object and its children and returns true on success.
 
int startTimer (int interval, Qt::TimerType timerType=Qt::CoarseTimer)
 This is an overloaded function that will start a timer of type timerType and a timeout of interval milliseconds.
 
int startTimer (std::chrono::nanoseconds time, Qt::TimerType timerType=Qt::CoarseTimer)
 
void killTimer (int id)
 Kills the timer with timer identifier, id.
 
void killTimer (Qt::TimerId id)
 
template<typename T >
findChild (QAnyStringView aName, Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 Returns the child of this object that can be cast into type T and that is called name, or \nullptr if there is no such object.
 
template<typename T >
QList< T > findChildren (QAnyStringView aName, Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects.
 
template<typename T >
findChild (Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
template<typename T >
QList< T > findChildren (Qt::FindChildOptions options=Qt::FindChildrenRecursively) const
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
 
const QObjectListchildren () const
 Returns a list of child objects.
 
void setParent (QObject *parent)
 Makes the object a child of parent.
 
void installEventFilter (QObject *filterObj)
 Installs an event filter filterObj on this object.
 
void removeEventFilter (QObject *obj)
 Removes an event filter object obj from this object.
 
QMetaObject::Connection connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const
 
bool disconnect (const char *signal=nullptr, const QObject *receiver=nullptr, const char *member=nullptr) const
 
bool disconnect (const QObject *receiver, const char *member=nullptr) const
 
void dumpObjectTree () const
 Dumps a tree of children to the debug output.
 
void dumpObjectInfo () const
 Dumps information about signal connections, etc.
 
bool setProperty (const char *name, const QVariant &value)
 Sets the value of the object's name property to value.
 
bool setProperty (const char *name, QVariant &&value)
 
QVariant property (const char *name) const
 Returns the value of the object's name property.
 
QList< QByteArraydynamicPropertyNames () const
 
QBindingStoragebindingStorage ()
 
const QBindingStoragebindingStorage () const
 
QObjectparent () const
 Returns a pointer to the parent object.
 
bool inherits (const char *classname) const
 Returns true if this object is an instance of a class that inherits className or a QObject subclass that inherits className; otherwise returns false.
 

Static Public Member Functions

static QGeoAreaMonitorSourcecreateDefaultSource (QObject *parent)
 Creates and returns a monitor source with the given parent that monitors areas using resources on the underlying system.
 
static QGeoAreaMonitorSourcecreateSource (const QString &sourceName, QObject *parent)
 Creates and returns a monitor source with the given parent, by loading the plugin named sourceName.
 
static QStringList availableSources ()
 Returns a list of available monitor plugins, including the default system backend if one is available.
 
- Static Public Member Functions inherited from QObject
static QMetaObject::Connection connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
 \threadsafe
 
static QMetaObject::Connection connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type=Qt::AutoConnection)
 
template<typename Func1 , typename Func2 >
static QMetaObject::Connection connect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const typename QtPrivate::ContextTypeForFunctor< Func2 >::ContextType *context, Func2 &&slot, Qt::ConnectionType type=Qt::AutoConnection)
 
template<typename Func1 , typename Func2 >
static QMetaObject::Connection connect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, Func2 &&slot)
 
static bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member)
 \threadsafe
 
static bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &member)
 
static bool disconnect (const QMetaObject::Connection &)
 Disconnect a connection.
 
template<typename Func1 , typename Func2 >
static bool disconnect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const typename QtPrivate::FunctionPointer< Func2 >::Object *receiver, Func2 slot)
 
template<typename Func1 >
static bool disconnect (const typename QtPrivate::FunctionPointer< Func1 >::Object *sender, Func1 signal, const QObject *receiver, void **zero)
 

Additional Inherited Members

- Public Slots inherited from QObject
void deleteLater ()
 \threadsafe
 
- Protected Member Functions inherited from QObject
QObjectsender () const
 Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; otherwise it returns \nullptr.
 
int senderSignalIndex () const
 
int receivers (const char *signal) const
 Returns the number of receivers connected to the signal.
 
bool isSignalConnected (const QMetaMethod &signal) const
 
virtual void timerEvent (QTimerEvent *event)
 This event handler can be reimplemented in a subclass to receive timer events for the object.
 
virtual void childEvent (QChildEvent *event)
 This event handler can be reimplemented in a subclass to receive child events.
 
virtual void customEvent (QEvent *event)
 This event handler can be reimplemented in a subclass to receive custom events.
 
virtual void connectNotify (const QMetaMethod &signal)
 
virtual void disconnectNotify (const QMetaMethod &signal)
 
 QObject (QObjectPrivate &dd, QObject *parent=nullptr)
 
- Protected Attributes inherited from QObject
QScopedPointer< QObjectDatad_ptr
 
- Properties inherited from QObject
QString objectName
 the name of this object
 

Detailed Description

\inmodule QtPositioning

Since
5.2

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

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 \l QGeoAreaMonitorInfo object. For example:

QGeoAreaMonitorSource follows a singleton pattern. Each instance of the class with the same \l sourceName() shares the same area monitoring backend. If a new \l QGeoAreaMonitorInfo object is added via \l startMonitoring() or \l 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 \l QGeoPositionInfoSource instance used by this class. The following code snippet emphasizes the behavior:

QVERIFY(s1->positionInfoSource() == s2->positionInfoSource);
\inmodule QtPositioning
static QGeoAreaMonitorSource * createSource(const QString &sourceName, QObject *parent)
Creates and returns a monitor source with the given parent, by loading the plugin named sourceName.
GLuint GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat GLfloat s1
#define s2
#define QVERIFY(statement)
Definition qtestcase.h:59

Definition at line 17 of file qgeoareamonitorsource.h.

Member Enumeration Documentation

◆ AreaMonitorFeature

Defines the types of area monitoring capabilities.

\value PersistentAreaMonitorFeature QGeoAreaMonitorInfo instances can be made persistent. A persistent monitor continues to be active even when the application managing the monitor is not running. \value AnyAreaMonitorFeature Matches all possible area monitoring features.

Enumerator
PersistentAreaMonitorFeature 
AnyAreaMonitorFeature 

Definition at line 30 of file qgeoareamonitorsource.h.

◆ Error

Defines the types of positioning methods.

The Error enumeration represents the errors which can occur.

\value AccessError The connection setup to the remote area monitoring backend failed because the application lacked the required privileges. \value 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. \value NoError No error has occurred. \value UnknownSourceError An unidentified error occurred.

Enumerator
AccessError 
InsufficientPositionInfo 
UnknownSourceError 
NoError 

Definition at line 22 of file qgeoareamonitorsource.h.

Constructor & Destructor Documentation

◆ QGeoAreaMonitorSource()

QGeoAreaMonitorSource::QGeoAreaMonitorSource ( QObject * parent)
explicit

Creates a monitor source with the given parent.

Definition at line 93 of file qgeoareamonitorsource.cpp.

◆ ~QGeoAreaMonitorSource()

QGeoAreaMonitorSource::~QGeoAreaMonitorSource ( )
virtual

Destroys the monitor source.

Definition at line 103 of file qgeoareamonitorsource.cpp.

Member Function Documentation

◆ activeMonitors() [1/2]

virtual QList< QGeoAreaMonitorInfo > QGeoAreaMonitorSource::activeMonitors ( ) const
pure virtual

Returns the list of all active monitors known to the QGeoAreaMonitorSource object.

An active monitor was started via startMonitoring(). For every active monitor the source object will emit the required signals, such as areaEntered() or areaExited(). Multiple \l QGeoAreaMonitorSource instances within the same application share the same active monitor objects.

Unless an active QGeoAreaMonitorInfo \l {QGeoAreaMonitorInfo::isPersistent()}{isPersistent()} an active QGeoAreaMonitorInfo will be stopped once the current application terminates.

Implemented in QGeoAreaMonitorPolling.

◆ activeMonitors() [2/2]

virtual QList< QGeoAreaMonitorInfo > QGeoAreaMonitorSource::activeMonitors ( const QGeoShape & lookupArea) const
pure virtual

Returns the list of all active monitors known to the QGeoAreaMonitorSource object whose center lies within lookupArea.

If lookupArea is empty the returned list will be empty.

An active monitor was started via startMonitoring(). For every active monitor the source object will emit the required signals, such as areaEntered() or areaExited(). Multiple \l QGeoAreaMonitorSource instances within the same application share the same active monitor objects.

Unless an active QGeoAreaMonitorInfo \l {QGeoAreaMonitorInfo::isPersistent()}{isPersistent()} an active QGeoAreaMonitorInfo will be stopped once the current application terminates.

See also
QGeoShape

Implemented in QGeoAreaMonitorPolling.

◆ areaEntered

void QGeoAreaMonitorSource::areaEntered ( const QGeoAreaMonitorInfo & monitor,
const QGeoPositionInfo & update )
signal

Emitted when the current position has moved from a position outside of the active monitor to a position within the monitored area.

The update holds the new position.

◆ areaExited

void QGeoAreaMonitorSource::areaExited ( const QGeoAreaMonitorInfo & monitor,
const QGeoPositionInfo & update )
signal

Emitted when the current position has moved from a position within the active monitor to a position outside the monitored area.

The update holds the new position.

◆ availableSources()

QStringList QGeoAreaMonitorSource::availableSources ( )
static

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

Definition at line 159 of file qgeoareamonitorsource.cpp.

◆ backendProperty()

QVariant QGeoAreaMonitorSource::backendProperty ( const QString & name) const
virtual
Since
6.2

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

See also
setBackendProperty()

Definition at line 210 of file qgeoareamonitorsource.cpp.

◆ createDefaultSource()

QGeoAreaMonitorSource * QGeoAreaMonitorSource::createDefaultSource ( QObject * parent)
static

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.

Definition at line 113 of file qgeoareamonitorsource.cpp.

◆ createSource()

QGeoAreaMonitorSource * QGeoAreaMonitorSource::createSource ( const QString & sourceName,
QObject * parent )
static

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

Returns nullptr if the plugin cannot be found.

Definition at line 138 of file qgeoareamonitorsource.cpp.

◆ error()

virtual Error QGeoAreaMonitorSource::error ( ) const
pure virtual

Returns the type of error that last occurred.

Note
Since Qt6 the last error is always reset when calling startMonitoring() or requestUpdate().

Implemented in QGeoAreaMonitorPolling.

◆ errorOccurred

void QGeoAreaMonitorSource::errorOccurred ( QGeoAreaMonitorSource::Error areaMonitoringError)
signal

This signal is emitted after an error occurred.

The areaMonitoringError parameter describes the type of error that occurred.

◆ monitorExpired

void QGeoAreaMonitorSource::monitorExpired ( const QGeoAreaMonitorInfo & monitor)
signal

Emitted when monitor has expired.

An expired area monitor is automatically removed from the list of \l activeMonitors().

See also
activeMonitors()

◆ positionInfoSource()

QGeoPositionInfoSource * QGeoAreaMonitorSource::positionInfoSource ( ) const
virtual

Returns the current QGeoPositionInfoSource used by this QGeoAreaMonitorSource object.

The function will return \l QGeoPositionInfoSource::createDefaultSource() if no other object has been set.

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

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

See also
QGeoPositionInfoSource, setPositionInfoSource()

Reimplemented in QGeoAreaMonitorPolling.

Definition at line 229 of file qgeoareamonitorsource.cpp.

◆ requestUpdate()

virtual bool QGeoAreaMonitorSource::requestUpdate ( const QGeoAreaMonitorInfo & monitor,
const char * signal )
pure virtual

Enables single shot area monitoring.

Area monitoring for monitor will be performed until this QGeoAreaMonitorSource instance emits signal for the first time. Once the signal was emitted, monitor is automatically removed from the list of \l activeMonitors(). If monitor is invalid or has an expiry date that has been passed, this function returns false.

QGeoAreaMonitor singleShotMonitor;
//...
bool ret = source->requestUpdate(singleShotMonitor,
SIGNAL(areaExited(QGeoAreaMonitor,QGeoPositionInfo)));
static QGeoAreaMonitorSource * createDefaultSource(QObject *parent)
Creates and returns a monitor source with the given parent that monitors areas using resources on the...
void areaExited(const QGeoAreaMonitorInfo &monitor, const QGeoPositionInfo &update)
Emitted when the current position has moved from a position within the active monitor to a position o...
\inmodule QtPositioning
return ret
[0]
#define SIGNAL(a)
Definition qobjectdefs.h:53
GLsizei GLsizei GLchar * source

The above singleShotMonitor object will cease to send updates once the \l areaExited() signal was emitted for the first time. Until this point in time any other signal may be emitted zero or more times depending on the area context.

It is not possible to simultanously request updates for more than one signal of the same monitor object. The last call to this function determines the signal upon which the updates cease to continue. At this stage only the \l areaEntered() and \l areaExited() signals can be used to terminate the monitoring process.

Requesting persistent monitoring on a QGeoAreaMonitorSource instance fails if the area monitoring backend doesn't support \l QGeoAreaMonitorSource::PersistentAreaMonitorFeature.

If monitor was already registered via \l startMonitoring() it is converted to a single shot behavior.

Note
Since Qt6 this method always resets the last error to \l {QGeoAreaMonitorSource::}{NoError} before starting monitoring.
See also
startMonitoring(), stopMonitoring()

Implemented in QGeoAreaMonitorPolling.

◆ setBackendProperty()

bool QGeoAreaMonitorSource::setBackendProperty ( const QString & name,
const QVariant & value )
virtual
Since
6.2

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.

See also
backendProperty()

Definition at line 195 of file qgeoareamonitorsource.cpp.

◆ setPositionInfoSource()

void QGeoAreaMonitorSource::setPositionInfoSource ( QGeoPositionInfoSource * newSource)
virtual

Sets the new \l QGeoPositionInfoSource to be used by this QGeoAreaMonitorSource object.

The area monitoring backend becomes the new QObject parent for newSource. The previous \l QGeoPositionInfoSource object will be deleted. All QGeoAreaMonitorSource instances based on the same \l 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.

See also
positionInfoSource()

Reimplemented in QGeoAreaMonitorPolling.

Definition at line 251 of file qgeoareamonitorsource.cpp.

◆ sourceName()

QString QGeoAreaMonitorSource::sourceName ( ) const

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.

Definition at line 179 of file qgeoareamonitorsource.cpp.

◆ startMonitoring()

virtual bool QGeoAreaMonitorSource::startMonitoring ( const QGeoAreaMonitorInfo & monitor)
pure virtual

Returns true if the monitoring of monitor could be successfully started; otherwise returns false.

A reason for not being able to start monitoring could be the unavailability of an appropriate default position info source while no alternative QGeoPositionInfoSource has been set via \l setPositionInfoSource().

If monitor is already active, the existing monitor object will be replaced by the new monitor reference. The identification of QGeoAreaMonitorInfo instances happens via \l QGeoAreaMonitorInfo::identifier(). Therefore this function can also be used to update active monitors.

If monitor has an expiry date that has been passed this function returns false. Calling this function for an already via \l requestUpdate() registered single shot monitor switches the monitor to a permanent monitoring mode.

Requesting persistent monitoring on a QGeoAreaMonitorSource instance fails if the area monitoring backend doesn't support \l QGeoAreaMonitorSource::PersistentAreaMonitorFeature.

Note
Since Qt6 this method always resets the last error to \l {QGeoAreaMonitorSource::}{NoError} before starting monitoring.
See also
stopMonitoring()

Implemented in QGeoAreaMonitorPolling.

◆ stopMonitoring()

virtual bool QGeoAreaMonitorSource::stopMonitoring ( const QGeoAreaMonitorInfo & monitor)
pure virtual

Returns true if monitor was successfully removed from the list of \l activeMonitors(); otherwise returns false.

This behavior is independent on whether monitor was registered via \l startMonitoring() or \l requestUpdate().

Implemented in QGeoAreaMonitorPolling.

◆ supportedAreaMonitorFeatures()

virtual AreaMonitorFeatures QGeoAreaMonitorSource::supportedAreaMonitorFeatures ( ) const
pure virtual

Returns the area monitoring features available to this source.

Implemented in QGeoAreaMonitorPolling.


The documentation for this class was generated from the following files: