- Qt 6.10
- Qt Positioning
- QML Types
- geoRectangle
- Qt 6.10.2 Reference Documentation

# geoRectangle QML Value Type

The geoRectangle type represents a rectangular geographic area. More...

Import Statement: | `import QtPositioning`

## Properties

- bottomLeft : geoCoordinate
- bottomRight : geoCoordinate
- center : geoCoordinate
- height : double
- topLeft : geoCoordinate
- topRight : geoCoordinate
- width : double

## Detailed Description

The geoRectangle type is a geoShape that represents a rectangular geographic area. The type is direct representation of a QGeoRectangle. It is defined by a pair of coordinates which represent the top-left and bottom-right corners of the rectangle. The coordinates are accessible from the topLeft and bottomRight attributes.

A rectangle is considered invalid if the top-left or bottom-right coordinates are invalid or if the top-left coordinate is south of the bottom-right coordinate.

The coordinates of the four corners of the rectangle can be accessed with the topLeft, topRight, bottomLeft and bottomRight attributes. The center attribute can be used to get the coordinate of the center of the rectangle. The width and height attributes can be used to get the width and height of the rectangle in degrees. Setting one of these attributes will cause the other attributes to be adjusted accordingly.

## Limitations

A geoRectangle can never cross the poles.

If the height or center of a geoRectangle is adjusted such that it would cross one of the poles the height is modified such that the rectangle touches but does not cross the pole and that the center coordinate is still in the center of the rectangle.

## Example Usage

To create a geoRectangle value, use the QtPositioning.rectangle() function:

     import QtPositioning

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

When integrating with C++, note that any QGeoRectangle value passed into QML from C++ is automatically converted into a geoRectangle value, and vice-versa.

## Property Documentation

bottomLeft : geoCoordinate

This property holds the bottom left coordinate of this geoRectangle.

bottomRight : geoCoordinate

This property holds the bottom right coordinate of this geoRectangle.

center : geoCoordinate

This property holds the center coordinate of this geoRectangle. For more details see QGeoRectangle::setCenter().

height : double

This property holds the height of this geoRectangle (in degrees). For more details see QGeoRectangle::setHeight().

Note: If the geoRectangle is invalid, it is not possible to set the height. QtPositioning releases prior to Qt 5.5 permitted the setting of the height even on invalid geoRectangles.

topLeft : geoCoordinate

This property holds the top left coordinate of this geoRectangle.

topRight : geoCoordinate

This property holds the top right coordinate of this geoRectangle.

width : double

This property holds the width of this geoRectangle (in degrees). For more details see QGeoRectangle::setWidth().

Note: If the geoRectangle is invalid, it is not possible to set the width. QtPositioning releases prior to Qt 5.5 permitted the setting of the width even on invalid geoRectangles.