QGeoLocation类
QGeoLocation类表示位置的基本信息。 更多...
| 头文件 | #include <QGeoLocation> | 
| CMake | find_package(Qt6 REQUIRED COMPONENTS Positioning) target_link_libraries(mytarget PRIVATE Qt6::Positioning) | 
| qmake | QT += positioning | 
公共函数
| QGeoLocation() | |
| QGeoLocation(const QGeoLocation &other) | |
| (自6.2起) | QGeoLocation(QGeoLocation &&other) | 
| ~QGeoLocation() | |
| QGeoAddress | address() const | 
| (自6.2起)QGeoShape | boundingShape() const | 
| QGeoCoordinate | coordinate() const | 
| QVariantMap | extendedAttributes() const | 
| bool | isEmpty() const | 
| void | setAddress(const QGeoAddress &address) | 
| (自6.2起)void | setBoundingShape(const QGeoShape &boundingShape) | 
| void | setCoordinate(const QGeoCoordinate &coordinate) | 
| void | setExtendedAttributes(const QVariantMap &data) | 
| QGeoLocation & | operator=(const QGeoLocation &other) | 
| (自6.2起)QGeoLocation & | operator=(QGeoLocation &&other) | 
相关非成员
| size_t | qHash(const QGeoLocation &location, size_t seed = 0) | 
| bool | operator!=(const QGeoLocation &lhs, const QGeoLocation &rhs) | 
| bool | operator==(const QGeoLocation &lhs, const QGeoLocation &rhs) | 
成员函数文档
QGeoLocation::QGeoLocation()
构建一个新的位置对象。
QGeoLocation::QGeoLocation(const QGeoLocation &other)
构建一个other的副本。
[异常安全,自6.2起] QGeoLocation::QGeoLocation(QGeoLocation &&other)
通过移动从一个位置创建地理定位对象。
注意:从该位置移动的QGeoLocation对象只能被销毁或赋值。调用析构函数或赋值运算符以外的其他函数的效果是未定义的。
此函数自Qt 6.2开始引入。
[noexcept] QGeoLocation::~QGeoLocation()
销毁位置对象。
QGeoAddress QGeoLocation::address() const
返回位置地址。
另请参阅:setAddress()。
[since 6.2] QGeoShape QGeoLocation::boundingShape() const
返回一个边界形状,表示查看此位置时推荐的显示区域。
例如,一栋楼的位置可能有一个以楼为中心的区域,但这个区域足够大,可以显示它的直接地理上下文。
注意:此方法在Qt6中引入,而不是boundingBox()方法。它返回一个QGeoShape而不是一个QGeoRectangle。使用QGeoShape::boundingGeoRectangle()来获取形状的边界QGeoRectangle。
此函数自Qt 6.2开始引入。
另请参阅:setBoundingShape()。
QGeoCoordinate QGeoLocation::coordinate() const
返回位置坐标。
另请参阅:setCoordinate()。
QVariantMap QGeoLocation::extendedAttributes() const
返回与该位置关联的扩展属性。扩展属性依赖于后端,并且可能与位置相关。
另请参阅:setExtendedAttributes()。
bool QGeoLocation::isEmpty() const
如果位置坐标无效,并且所有其他位置字段为空,则返回true。否则返回false。
void QGeoLocation::setAddress(const QGeoAddress &address)
设置位置地址。
另请参阅:address()。
[since 6.2] void QGeoLocation::setBoundingShape(const QGeoShape &boundingShape)
设置位置的边界形状。
此函数自Qt 6.2开始引入。
另请参阅:boundingShape()。
void QGeoLocation::setCoordinate(const QGeoCoordinate &coordinate)
设置位置的坐标。
另请参阅:coordinate()。
void QGeoLocation::setExtendedAttributes(const QVariantMap &data)
使用在data中指定的参数设置位置的扩展属性。
另请参阅 extendedAttributes。
QGeoLocation &QGeoLocation::operator=(const QGeoLocation &other)
将要把 other 赋值给当前位置,并返回对此当前位置的引用。
[noexcept, since 6.2] QGeoLocation &QGeoLocation::operator=(QGeoLocation &&other)
将 other 移动赋予此位置,并返回对此位置的引用。
注意: 被移动的 QGeoLocation 对象只能被销毁或赋值。调用除了析构函数或赋值运算符之外的其他函数的效果是未定义的。
此函数自Qt 6.2开始引入。
相关非成员
[noexcept] size_t qHash(const QGeoLocation &location, size_t seed = 0)
返回 location 的哈希值,使用 seed 进行计算。
注意: 哈希值不考虑扩展属性。这意味着只有扩展属性不同的两个地理位置对象将提供相似的哈希值。
bool operator!=(const QGeoLocation &lhs, const QGeoLocation &rhs)
如果 lhs 位置不等于 rhs,则返回 true,否则返回 false。
bool operator==(const QGeoLocation &lhs, const QGeoLocation &rhs)
如果 lhs 位置等于 rhs,则返回 true,否则返回 false。
© 2024 Qt公司有限公司。在此包含的文档贡献是各自所有者的版权。在此提供的文档根据自由软件基金会发布的 GNU自由文档许可协议版本1.3 的条款许可。Qt及其相关标志是芬兰及其他国家的 Qt公司有限公司的商标。所有其他商标为其各自所有者。