geoshape QML Value Type

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

Import Statement: import QtPositioning

详细说明

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

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

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

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

使用示例

使用var 类型的属性来存储geoshape 。要创建geoshape ,请使用下面描述的方法之一。

要创建geoshape 值,请将其指定为 "shape() "字符串:

import QtPositioning

Item {
    property var region: "shape()"
}

或使用QtPositioning.shape() 函数:

import QtPositioning

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

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

属性

是空

bool isEmpty

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

有效

bool isValid

返回此几何形状是否有效。

如果没有设置明确描述该几何形状所需的某些数据,或这些数据被设置为不合适的值,则该几何形状被视为无效。

类型

ShapeType type

返回形状的当前类型。

  • GeoShape.UnknownType - 形状类型未知。
  • GeoShape.RectangleType - 形状是 。georectangle
  • GeoShape.CircleType - 形状是 。geocircle
  • GeoShape.PathType - 形状是 。(自 Qt 5.9 起)geopath
  • GeoShape.PolygonType - 形状是 。(自 Qt 5.10 起)geopolygon

此 QML 属性由 Qt 5.5 引入。

方法

包含()

bool contains(coordinate coord)

如果coord 指定的coordinate 位于此 geoshape 内,则返回 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.