geoRectangle QML Value Type

geoRectangle 类型表示矩形地理区域。更多

Import Statement: import QtPositioning

属性

详细说明

geoRectangle 类型是表示矩形地理区域的geoShape 。该类型直接表示QGeoRectangle 。它由一对coordinates 定义,这对 表示矩形的左上角和右下角。坐标可通过topLeftbottomRight 属性获取。

如果左上角或右下角坐标无效,或者左上角坐标在右下角坐标的南边,则矩形被视为无效。

矩形四个角的坐标可通过topLefttopRightbottomLeftbottomRight 属性访问。center 属性可用于获取矩形中心的坐标。widthheight 属性可用于获取矩形的宽度和高度(单位:度)。设置其中一个属性会相应调整其他属性。

限制条件

地理矩形永远不能跨越两极。

如果调整了地理矩形的高度或中心,使其与某个极点相交,则会修改高度,使矩形接触但不与极点相交,并且中心坐标仍位于矩形的中心。

使用示例

要创建一个 geoRectangle 值,请使用QtPositioning.rectangle() 函数:

import QtPositioning

Item {
    property geoRectangle region: QtPositioning.rectangle(QtPositioning.coordinate(-27.5, 153.1),
                                                          QtPositioning.coordinate(-27.6, 153.2))
}

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

属性文档

bottomLeft : geoCoordinate

此属性保存此geoRectangle 的左下角坐标。


bottomRight : geoCoordinate

此属性保存此geoRectangle 的右下坐标。


center : geoCoordinate

此属性保存此geoRectangle 的中心坐标。有关详细信息,请参阅QGeoRectangle::setCenter() 。


height : double

该属性表示geoRectangle 的高度(单位:度)。有关详细信息,请参阅QGeoRectangle::setHeight() 。

注意: 如果geoRectangle 无效,则无法设置高度。Qt 5.5 之前的QtPositioning 版本允许在无效的 geoRectangles 上设置高度。


topLeft : geoCoordinate

此属性保存此geoRectangle 的左上角坐标。


topRight : geoCoordinate

该属性表示geoRectangle 的右上角坐标。


width : double

该属性表示geoRectangle 的宽度(单位:度)。更多详情,请参阅QGeoRectangle::setWidth() 。

注意: 如果geoRectangle 无效,则无法设置宽度。Qt 5.5 之前的QtPositioning 版本允许在无效的 geoRectangles 上设置宽度。


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