QGeoAreaMonitor

Since: 1.0

#include <QtLocationSubset/QGeoAreaMonitor>

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

A QGeoAreaMonitor emits signals when the current position is in range, or has moved out of range, of a specified circular area. The area is specified by a coordinate (the center point) and a radius (in meters).

For example:

// This enables the SIGNAL()/SLOT() macros to have matching signatures.
using ::QtMobilitySubset::QGeoPositionInfo;
.
.
.
    public:
        MyClass::MyClass()
        {
            QGeoAreaMonitor *monitor = QGeoAreaMonitor::createDefaultMonitor();
            connect(monitor, SIGNAL(areaEntered(QGeoPositionInfo)),
                    this, SLOT(areaEntered(QGeoPositionInfo)));
            connect(monitor, SIGNAL(areaExited(QGeoPositionInfo)),
                    this, SLOT(areaExited(QGeoPositionInfo)));

            QGeoCoordinate bigBenLocation(51.50104, -0.124632);
            monitor->setCenter(bigBenLocation);
            monitor->setRadius(100);
        }

    public Q_SLOTS:
        void areaEntered(const QGeoPositionInfo &update)
        {
            qDebug() << "Now within 100 meters, current position is" << update.coordinate();
        }

        void areaExited(const QGeoPositionInfo &update)
        {
            qDebug() << "No longer within 100 meters, current position is" << update.coordinate();
        }

Overview

Properties Index

Public Functions Index

QGeoAreaMonitor (QObject *parent)
~QGeoAreaMonitor ()=0
QGeoCoordinatecenter () const
qrealradius () const
virtual voidsetCenter (const QGeoCoordinate &coordinate)
virtual voidsetRadius (qreal radius)

Static Public Functions Index

Signals Index

voidareaEntered (const QGeoPositionInfo &update)
voidareaExited (const QGeoPositionInfo &update)

Properties

QGeoCoordinate center

holds the center of the area to be monitored.

When the center is set, if the radius has already been set and the current position is within the monitored area, areaEntered() is emitted immediately.

By default, contains an invalid coordinate.

Note: Subclass implementations must call the base implementation of setCenter() so that center() returns the correct value.

qreal radius

holds the radius of the area to be monitored, in meters.

If the specified radius is less than the minimum supported radius, the radius is set to the minimum radius.

When this property is set, if the center coordinate has already been set and the current position is within the monitored area, areaEntered() is emitted immediately.

By default, this property is 0.

Note: Subclass implementations must call the base implementation of setRadius() so that radius() returns the correct value.

Public Functions

QGeoAreaMonitor (

Creates a monitor with the given parent.

~QGeoAreaMonitor ()

Destructor.

QGeoCoordinate center ()

qreal radius ()

virtual void setCenter (

virtual void setRadius (
  • qrealradius)

Static Public Functions

QGeoAreaMonitor * createDefaultMonitor (

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

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

Signals

void areaEntered (

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

The update holds the new position.

Note that QGeoAreaMonitor is in the namespace QtMobilitySubset and this signal is not declared by fully qualifying the QGeoPositionInfo parameter. Thus care must be taken when declaring a slot for connection to this signal. For examples see the descriptions for QGeoAreaMonitor and QGeoPositionInfoSource::positionUpdated().

void areaExited (

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

The update holds the new position.

Note that QGeoAreaMonitor is in the namespace QtMobilitySubset and this signal is not declared by fully qualifying the QGeoPositionInfo parameter. Thus care must be taken when declaring a slot for connection to this signal. For examples see the descriptions for QGeoAreaMonitor and QGeoPositionInfoSource::positionUpdated().

Last modified: 2014-06-24



Got questions about leaving a comment? Get answers from our Disqus FAQ.

comments powered by Disqus