本页内容

geoShape QML Value Type

geoShape 类型表示一个抽象的地理区域。更多内容...

Import Statement: import QtPositioning

属性

方法

详细说明

该类型是QGeoShape 的QML表示形式, 是一种抽象的地理区域。它包含所有地理区域共有的属性和方法。要创建表示有效地理区域的对象,请使用geoRectangle 或geoCircle 。

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 5.9 起)
  • GeoShape.PolygonType - 该形状为geoPolygon 。(自 Qt 5.10 起)

该 Qml 属性由 Qt 5.5 引入。

方法文档

bool contains(geoCoordinate coord)

如果由 `coord ` 指定的 `coordinate ` 位于该形状范围内,则返回 `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.