本页内容

QGeoShape Class

QGeoShape 类定义了一个地理区域。更多内容...

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

QGeoCircle、QGeoPath 、QGeoPolygon ,以及QGeoRectangle

公共类型

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 实例和以米为单位的距离来描述相关区域的具体细节。

在 QML 中,该类也可通过geoShape 访问。

成员类型文档

enum QGeoShape::ShapeType

描述形状的类型。

常量值描述
QGeoShape::UnknownType0类型未知的形状
QGeoShape::RectangleType1矩形形状
QGeoShape::CircleType2圆形
QGeoShape::PathType3路径类型
QGeoShape::PolygonType4多边形类型

属性文档

[read-only] center : QGeoCoordinate

该属性存储了图形几何中心的坐标。

访问函数:

QGeoCoordinate center() const

[read-only] isEmpty : bool

该属性用于定义该地理形状是否为空。

空的几何形状是指几何面积为 0 的区域。

虽然该属性是在 Qt 5.5 中引入的,但相关的访问器函数自该类的第一个版本起就已存在。

访问函数:

bool isEmpty() const

[read-only] isValid : bool

该属性表示地理形状的有效性。

如果某些用于明确描述地理形状的必填数据未被设置,或者根据该对象的子类被设置为不合适的值,则该地理形状将被视为无效。此类型的默认构造对象均为无效的。

虽然该属性是在 Qt 5.5 中引入的,但相关的访问器函数自该类的首个版本起便已存在。

访问函数:

bool isValid() const

[read-only] type : 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

返回几何形状几何中心的坐标。

注意: 这是 center 属性的获取 函数。

[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

返回该地理形状的类型。

注意: 这是用于获取 type 属性的获取器 函数。

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 。

© 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.