QGeoShape Class
QGeoShape 类定义了一个地理区域。更多
头文件: | #include <QGeoShape> |
CMake: | find_package(Qt6 REQUIRED COMPONENTS Positioning) target_link_libraries(mytarget PRIVATE Qt6::Positioning) |
qmake: | QT += positioning |
继承者: |
公共类型
enum | ShapeType { UnknownType, RectangleType, CircleType, PathType, PolygonType } |
属性
公共职能
QGeoShape() | |
QGeoShape(const QGeoShape &other) | |
~QGeoShape() | |
QGeoRectangle | boundingGeoRectangle() const |
QGeoCoordinate | center() const |
bool | contains(const QGeoCoordinate &coordinate) const |
bool | isEmpty() const |
bool | isValid() const |
QString | toString() const |
QGeoShape::ShapeType | type() const |
QGeoShape & | operator=(const QGeoShape &other) |
相关非成员
size_t | qHash(const QGeoShape &shape, size_t seed = 0) |
bool | operator!=(const QGeoShape &lhs, const QGeoShape &rhs) |
bool | operator==(const QGeoShape &lhs, const QGeoShape &rhs) |
详细说明
该类是指定地理区域的类的基类。
为保持一致性,子类应以QGeoCoordinate 实例和米为单位的距离来描述相关区域的具体细节。
自 Qt 5.5 起,该类是Q_GADGET 。它可直接用于 C++ 和 QML。
成员类型文档
enum QGeoShape::ShapeType
描述形状的类型。
常数 | 值 | 描述 |
---|---|---|
QGeoShape::UnknownType | 0 | 未知类型的形状 |
QGeoShape::RectangleType | 1 | 矩形 |
QGeoShape::CircleType | 2 | 圆形 |
QGeoShape::PathType | 3 | 路径类型 |
QGeoShape::PolygonType | 4 | 多边形类型 |
属性文档
[read-only]
isEmpty : const bool
该属性定义地理坐标形状是否为空。
空地理形状是指几何面积为 0 的区域。
虽然该属性是在 Qt 5.5 中引入的,但相关的访问函数在该类的第一个版本中就已存在。
访问函数:
bool | isEmpty() const |
[read-only]
isValid : const bool
该属性表示地理坐标形状的有效性。
如果未设置明确描述地理形状所需的某些数据,或根据该对象的子类设置了不合适的值,则该地理形状被视为无效。该类型的默认构造对象无效。
虽然该属性是在 Qt 5.5 中引入的,但相关的访问函数在该类的第一个版本中就已存在。
访问函数:
bool | isValid() const |
[read-only]
type : const ShapeType
该属性表示该地理形状的类型。
虽然该属性是在 Qt 5.5 中引入的,但相关的访问函数在该类的第一个版本中就已存在。
访问函数:
QGeoShape::ShapeType | type() const |
成员函数文档
QGeoShape::QGeoShape()
构建一个新的无效地理坐标形状UnknownType 。
[invokable]
QGeoShape::QGeoShape(const QGeoShape &other)
构造一个新的地理形状,它是other 的副本。
注: 可通过元对象系统和 QML 调用此函数。请参见Q_INVOKABLE 。
[noexcept]
QGeoShape::~QGeoShape()
破坏该地理形状。
[invokable]
QGeoRectangle QGeoShape::boundingGeoRectangle() const
返回代表地理坐标形状地理边界矩形的QGeoRectangle ,该矩形定义了地理坐标形状的经纬度边界。
注: 可通过元对象系统和 QML 调用此函数。请参见Q_INVOKABLE 。
QGeoCoordinate QGeoShape::center() const
返回位于地理坐标形状几何中心的坐标。
注: 属性中心的获取函数。
[invokable]
bool QGeoShape::contains(const QGeoCoordinate &coordinate) const
返回坐标coordinate 是否包含在此地理形状中。
注: 可通过元对象系统和 QML 调用此函数。请参阅Q_INVOKABLE 。
bool QGeoShape::isEmpty() const
返回该地理坐标是否为空。
空地理坐标形状是指几何面积为 0 的区域。
注: 属性 isEmpty 的获取函数。
bool QGeoShape::isValid() const
返回该地理坐标是否有效。
注: isValid 属性的获取函数。
[invokable]
QString QGeoShape::toString() const
返回该地理形状的字符串表示。
注: 可通过元对象系统和 QML 调用此函数。请参见Q_INVOKABLE 。
QGeoShape::ShapeType QGeoShape::type() const
返回该地理坐标的类型。
注: 属性类型的获取函数。
QGeoShape &QGeoShape::operator=(const QGeoShape &other)
为该地理坐标分配other 并返回该地理坐标的引用。
相关非会员
[noexcept]
size_t qHash(const QGeoShape &shape, size_t seed = 0)
返回shape 的哈希值,使用seed 进行计算。
bool operator!=(const QGeoShape &lhs, const QGeoShape &rhs)
如果lhs 地理坐标形状不等同于rhs 地理坐标形状,则返回true
,否则返回false
。
bool operator==(const QGeoShape &lhs, const QGeoShape &rhs)
如果lhs 地理坐标形状等同于rhs 地理坐标形状,则返回true
,否则返回false
。
© 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.