本页内容

geoRectangle QML Value Type

geoRectangle 类型表示一个矩形地理区域。更多内容...

Import Statement: import QtPositioning

属性

详细说明

geoRectangle 类型是一种geoShape ,用于表示矩形地理区域。该类型是QGeoRectangle 的直接表示。它由一组coordinates 定义,该坐标对分别表示矩形的左上角和右下角。可通过topLeft 和bottomRight 属性访问这些坐标。

如果左上角或右下角的坐标无效,或者左上角坐标位于右下角坐标以南,则该矩形被视为无效。

可以通过topLeft 、topRight 、bottomLeft 和bottomRight 属性获取矩形四个角的坐标。center 属性可用于获取矩形中心的坐标。width 和height 属性可用于获取矩形的宽度和高度(单位为度)。设置其中一个属性将导致其他属性相应调整。

限制

geoRectangle 绝不能跨越两极。

如果调整 geoRectangle 的高度或中心位置,导致其将穿过其中一个极点,则系统会调整高度,使矩形仅接触但不穿过该极点,同时确保中心坐标仍位于矩形中心。

使用示例

要创建 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 版本允许即使在 无效的情况下仍可设置高度。

topLeft : geoCoordinate

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

topRight : geoCoordinate

该属性存储了此geoRectangle 的右上角坐标。

width : double

该属性存储此geoRectangle 的宽度(以度为单位)。更多详细信息请参阅QGeoRectangle::setWidth()。

注意:如果 geoRectangle 无效,则无法设置宽度。Qt 5.5之前的QtPositioning 版本允许即使在 无效的情况下仍可设置宽度。

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