geoShape QML Value Type

geoShape 类型代表一个抽象的地理区域。更多

Import Statement: import QtPositioning

属性

方法

详细说明

该类型是QGeoShape 的 QML 表示,它是一个抽象的地理区域。它包括所有地理区域共有的属性和方法。要创建代表有效地理区域的对象,请使用geoRectanglegeoCircle

isValid 属性可用于测试形状是否代表有效的地理区域。

isEmpty 属性可用于测试形状是否代表几何面积为 0 的区域。

contains() 方法可用于测试geoCoordinate 是否在形状内。

使用示例

要创建 geoShape 值,请使用QtPositioning.shape() 函数:

import QtPositioning

Item {
    property geoShape region: QtPositioning.shape()
}

当与 C++ 整合时,请注意任何从 C++ 传入 QML 的QGeoShape 值都会自动转换为 geoShape 值,反之亦然。

属性文档

isEmpty : bool

返回此形状是否为空。空形状是指几何面积为 0 的区域。


isValid : bool

返回此形状是否有效。

如果未设置明确描述形状所需的某些数据,或将这些数据设置为不合适的值,则认为形状无效。


type : ShapeType

返回形状的当前类型。

  • GeoShape.UnknownType - 形状类型未知。
  • GeoShape.RectangleType - 形状是geoRectangle
  • GeoShape.CircleType - 形状是geoCircle
  • GeoShape.PathType - 形状是geoPath 。(自 Qt XML 5.9 起)
  • GeoShape.PolygonType - 形状是geoPolygon 。(自 Qt 5.10 起)

此 QML 属性由 Qt 5.5 引入。


方法文档

bool contains(geoCoordinate coord)

如果由coord 指定的coordinate 在此形状内,则返回 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.