georectangle QML Value Type

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

Import Statement: import QtPositioning

详细说明

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

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

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

限制条件

georectangle 永远不能越过两极。

如果对georectangle 的高度或中心进行调整,使其与某个极点相交,则会修改高度,使georectangle 与极点相交,但不与极点相交,并且中心坐标仍位于georectangle 的中心。

使用示例

使用var 类型的属性来存储georectangle 。要创建georectangle 值,请使用QtPositioning.rectangle() 函数:

import QtPositioning

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

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

属性

左下角

coordinate bottomLeft

此属性保存此地理矩形的左下角坐标。

右下角

coordinate bottomRight

该属性用于保存此地理矩形的右下坐标。

中心

coordinate center

此属性用于保存此georectangle 的中心坐标。更多详情请查看QGeoRectangle::setCenter().

高度

double height

该属性用于保存此georectangle 的高度(单位:度)。更多详情请参见QGeoRectangle::setHeight()。

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

左上角

coordinate topLeft

此属性用于保存此georectangle 的左上角坐标。

右上角

coordinate topRight

该属性用于保存此georectangle的右上角坐标。

宽度

double width

该属性用于保存此georectangle 的宽度(单位:度)。更多详情请查看QGeoRectangle::setWidth().

注意: 如果地理矩形无效,则无法设置宽度。QtPositioning Qt 5.5 之前的版本允许设置宽度,即使是无效的地理矩形。

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