QGeoAreaMonitorInfo Class

QGeoAreaMonitorInfo 类描述了要进行近距离监控的区域或地区的参数。更多

头文件: #include <QGeoAreaMonitorInfo>
CMake: find_package(Qt6 REQUIRED COMPONENTS Positioning)
target_link_libraries(mytarget PRIVATE Qt6::Positioning)
qmake: QT += positioning

公共函数

QGeoAreaMonitorInfo(const QString &name = QString())
QGeoAreaMonitorInfo(const QGeoAreaMonitorInfo &other)
(since 6.2) QGeoAreaMonitorInfo(QGeoAreaMonitorInfo &&other)
~QGeoAreaMonitorInfo()
QGeoShape area() const
QDateTime expiration() const
QString identifier() const
bool isPersistent() const
bool isValid() const
QString name() const
QVariantMap notificationParameters() const
void setArea(const QGeoShape &newShape)
void setExpiration(const QDateTime &expiry)
void setName(const QString &name)
void setNotificationParameters(const QVariantMap &parameters)
void setPersistent(bool isPersistent)
(since 6.2) void swap(QGeoAreaMonitorInfo &other)
(since 6.2) QGeoAreaMonitorInfo &operator=(QGeoAreaMonitorInfo &&other)
QGeoAreaMonitorInfo &operator=(const QGeoAreaMonitorInfo &other)
bool operator!=(const QGeoAreaMonitorInfo &lhs, const QGeoAreaMonitorInfo &rhs)
QDataStream &operator<<(QDataStream &stream, const QGeoAreaMonitorInfo &monitor)
bool operator==(const QGeoAreaMonitorInfo &lhs, const QGeoAreaMonitorInfo &rhs)
QDataStream &operator>>(QDataStream &stream, QGeoAreaMonitorInfo &monitor)

详细说明

区域监控的目的是在用户接近感兴趣的区域时通知他/她。一般来说,这样的区域由QGeoCircle 描述。圆心代表感兴趣的地方,其周围的区域则表示发送通知的地理区域。

如果 QGeoAreaMonitorInfo 对象的名称不是空的,且area() 有效,则该对象有效。此类对象必须通过QGeoAreaMonitorSource 注册,才能启动和停止监控进程。请注意,大范围监控可能会非常消耗资源,因为定位引擎必须保持激活状态,并且必须将当前位置与每个 QGeoAreaMonitorInfo 实例相匹配。

为了进一步减轻系统负担,可以设置一些可选属性。每个监控区域都可以有一个到期日期,一旦到了到期日期,就会自动从监控源中删除待监控区域。另一个选项是调整受监控区域的持久性。isPersistent() 的 QGeoAreaMonitorInfo 将在当前应用程序生命周期结束后保持激活状态。如果在监控程序未运行时进入某个区域,该程序将被启动。请注意,该功能并非在所有平台上都可用。可通过QGeoAreaMonitorSource::supportedAreaMonitorFeatures() 查看是否可用。

另请参阅 QGeoAreaMonitorSource

成员函数文档

[explicit] QGeoAreaMonitorInfo::QGeoAreaMonitorInfo(const QString &name = QString())

用指定的name 构建一个 QGeoAreaMonitorInfo 对象。

另请参阅 name().

QGeoAreaMonitorInfo::QGeoAreaMonitorInfo(const QGeoAreaMonitorInfo &other)

构造一个 QGeoAreaMonitorInfo 对象,作为other 的副本。

[noexcept, since 6.2] QGeoAreaMonitorInfo::QGeoAreaMonitorInfo(QGeoAreaMonitorInfo &&other)

通过从other 移动构建一个 QGeoAreaMonitorInfo 对象。

请注意,从移动的 QGeoAreaMonitorInfo 只能被销毁或赋值。调用析构函数或赋值操作符之外的其他函数的效果未定义。

此函数在 Qt 6.2 中引入。

[noexcept] QGeoAreaMonitorInfo::~QGeoAreaMonitorInfo()

销毁器

QGeoShape QGeoAreaMonitorInfo::area() const

返回待监控区域的边界。该区域不得为空。

另请参阅 setArea()。

QDateTime QGeoAreaMonitorInfo::expiration() const

返回过期日期。

有效QGeoAreaMonitorInfo 过期后,该区域将不再受监控,QGeoAreaMonitorInfo 对象将从active monitors 列表中删除。

如果过期QDateTime 无效,则QGeoAreaMonitorInfo 对象将被视为没有过期日期。如果对象是持久性的,这意味着监控期是无限期的;如果对象是非持久性的,这意味着监控期将一直持续到当前应用程序关闭为止。

另请参阅 setExpiration() 和QGeoAreaMonitorSource::activeMonitors()。

QString QGeoAreaMonitorInfo::identifier() const

返回QGeoAreaMonitorInfo 对象的标识符。该标识符会在创建新的QGeoAreaMonitorInfo 对象时自动生成。

bool QGeoAreaMonitorInfo::isPersistent() const

如果QGeoAreaMonitorInfo 是持久的,则返回 true。此属性的默认值为 false。

一旦拥有监控对象的应用程序停止运行,非持久QGeoAreaMonitorInfo 将被系统删除。持久对象将保持活动状态,并可在应用程序重新启动后检索。

如果系统触发了与持久QGeoAreaMonitorInfo 相关的事件,相关应用程序将重新启动,并发出相应的信号。

另请参见 setPersistent()。

bool QGeoAreaMonitorInfo::isValid() const

如果监视器有效,则返回 true。有效的QGeoAreaMonitorInfo 有一个非空的name() ,且监控区域不是empty() 。否则,此函数返回 false。

QString QGeoAreaMonitorInfo::name() const

返回QGeoAreaMonitorInfo 对象的名称。该名称应用于用户可见性目的。

另请参阅 setName()。

QVariantMap QGeoAreaMonitorInfo::notificationParameters() const

返回QGeoAreaMonitorInfo 使用的平台特定参数集。

另请参见 setNotificationParameters()。

void QGeoAreaMonitorInfo::setArea(const QGeoShape &newShape)

将待监控区域设置为newShape

另请参阅 area() 。

void QGeoAreaMonitorInfo::setExpiration(const QDateTime &expiry)

将到期日期和时间设置为expiry

另请参阅 expiration() 。

void QGeoAreaMonitorInfo::setName(const QString &name)

设置用户可见name

另请参阅 name() 。

void QGeoAreaMonitorInfo::setNotificationParameters(const QVariantMap &parameters)

设置QGeoAreaMonitorInfo 使用的特定平台parameters

另请参阅 notificationParameters() 。

void QGeoAreaMonitorInfo::setPersistent(bool isPersistent)

QGeoAreaMonitorInfo 对象的持久性设置为isPersistent

请注意,设置此标志并不意味着QGeoAreaMonitorSource 支持持久性监控。QGeoAreaMonitorSource::supportedAreaMonitorFeatures() 可用于检查此功能是否可用。

另请参阅 isPersistent() 。

[noexcept, since 6.2] void QGeoAreaMonitorInfo::swap(QGeoAreaMonitorInfo &other)

QGeoAreaMonitorInfo 对象与other 互换。该操作速度非常快,而且不会失败。

此函数在 Qt 6.2 中引入。

[noexcept, since 6.2] QGeoAreaMonitorInfo &QGeoAreaMonitorInfo::operator=(QGeoAreaMonitorInfo &&other)

Move 将other 分配给该QGeoAreaMonitorInfo 对象,并返回对该QGeoAreaMonitorInfo 对象的引用。

请注意,move-fromQGeoAreaMonitorInfo 只能被销毁或赋值。调用析构函数或赋值操作符之外的其他函数的效果未定义。

此函数在 Qt 6.2 中引入。

QGeoAreaMonitorInfo &QGeoAreaMonitorInfo::operator=(const QGeoAreaMonitorInfo &other)

other 赋值给QGeoAreaMonitorInfo 对象,并返回对QGeoAreaMonitorInfo 对象的引用。

相关非成员

bool operator!=(const QGeoAreaMonitorInfo &lhs, const QGeoAreaMonitorInfo &rhs)

如果lhs 对象的任何值与rhs 对象的值不一致,则返回true 。否则返回false

QDataStream &operator<<(QDataStream &stream, const QGeoAreaMonitorInfo &monitor)

将给定的monitor 写入指定的stream

另请参阅 序列化 Qt 数据类型

bool operator==(const QGeoAreaMonitorInfo &lhs, const QGeoAreaMonitorInfo &rhs)

如果lhs 对象的所有值都与rhs 对象的值相同,则返回true 。否则返回false

QDataStream &operator>>(QDataStream &stream, QGeoAreaMonitorInfo &monitor)

从指定的stream 中读取区域监控数据到给定的monitor 中。

另请参阅 序列化 Qt 数据类型

© 2025 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.