QGeoAreaMonitorInfo Class
QGeoAreaMonitorInfo 类描述了用于监视邻近性的某个区域或地带的参数。更多内容...
| 头文件: | #include <QGeoAreaMonitorInfo> |
| CMake: | find_package(Qt6 REQUIRED COMPONENTS Positioning) target_link_libraries(mytarget PRIVATE Qt6::Positioning) |
| qmake: | QT += positioning |
- 所有成员的列表,包括继承的成员
- QGeoAreaMonitorInfo 属于“隐式共享类”。
公共函数
| 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 ¶meters) |
| 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 的副本。
[constexpr noexcept default, 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 ¶meters)
设置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)
该操作将other 移入并赋值给此QGeoAreaMonitorInfo 对象,并返回对此QGeoAreaMonitorInfo 对象的引用。
请注意,被移出的QGeoAreaMonitorInfo 只能被销毁或被赋值。调用除析构函数或赋值运算符以外的其他函数,其行为未定义。
该函数在 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 数据类型的序列化》。
© 2026 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.