QGeoShape Class

The QGeoShape class defines a geographic area. More...

Header: #include <QGeoShape>
CMake: find_package(Qt6 COMPONENTS Positioning REQUIRED)
target_link_libraries(mytarget PRIVATE Qt6::Positioning)
qmake: QT += positioning
Since: Qt 5.2
Inherited By:

QGeoCircle, QGeoPath, QGeoPolygon, and QGeoRectangle

Public Types

enum ShapeType { UnknownType, RectangleType, CircleType, PathType, PolygonType }

Properties

Public Functions

QGeoShape(const QGeoShape &other)
QGeoShape()
QGeoShape &operator=(const QGeoShape &other)
~QGeoShape()
QGeoRectangle boundingGeoRectangle() const
QGeoCoordinate center() const
bool contains(const QGeoCoordinate &coordinate) const
bool isEmpty() const
bool isValid() const
QString toString() const
QGeoShape::ShapeType type() const
size_t qHash(const QGeoShape &shape, size_t seed = 0)
bool operator!=(const QGeoShape &lhs, const QGeoShape &rhs)
bool operator==(const QGeoShape &lhs, const QGeoShape &rhs)

Detailed Description

This class is the base class for classes which specify a geographic area.

For the sake of consistency, subclasses should describe the specific details of the associated areas in terms of QGeoCoordinate instances and distances in meters.

This class is a Q_GADGET since Qt 5.5. It can be directly used from C++ and QML.

Member Type Documentation

enum QGeoShape::ShapeType

Describes the type of the shape.

ConstantValueDescription
QGeoShape::UnknownType0A shape of unknown type
QGeoShape::RectangleType1A rectangular shape
QGeoShape::CircleType2A circular shape
QGeoShape::PathType3A path type
QGeoShape::PolygonType4A polygon type

Property Documentation

[read-only, since 5.5] isEmpty : const bool

This property defines whether this geo shape is empty.

An empty geo shape is a region which has a geometrical area of 0.

While this property is introduced in Qt 5.5, the related accessor functions exist since the first version of this class.

This property was introduced in Qt 5.5.

Access functions:

bool isEmpty() const

[read-only, since 5.5] isValid : const bool

This property holds the validity of the geo shape.

A geo shape is considered to be invalid if some of the data that is required to unambiguously describe the geo shape has not been set or has been set to an unsuitable value depending on the subclass of this object. The default constructed objects of this type are invalid.

While this property is introduced in Qt 5.5, the related accessor functions exist since the first version of this class.

This property was introduced in Qt 5.5.

Access functions:

bool isValid() const

[read-only, since 5.5] type : const ShapeType

This property holds the type of this geo shape.

While this property is introduced in Qt 5.5, the related accessor functions exist since the first version of this class.

This property was introduced in Qt 5.5.

Access functions:

QGeoShape::ShapeType type() const

Member Function Documentation

QGeoShape::QGeoShape(const QGeoShape &other)

Constructs a new geo shape which is a copy of other.

QGeoShape::QGeoShape()

Constructs a new invalid geo shape of UnknownType.

QGeoShape &QGeoShape::operator=(const QGeoShape &other)

Assigns other to this geo shape and returns a reference to this geo shape.

QGeoShape::~QGeoShape()

Destroys this geo shape.

[invokable, since 5.9] QGeoRectangle QGeoShape::boundingGeoRectangle() const

Returns a QGeoRectangle representing the geographical bounding rectangle of the geo shape, that defines the latitudinal/longitudinal bounds of the geo shape.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

This function was introduced in Qt 5.9.

[since 5.5] QGeoCoordinate QGeoShape::center() const

Returns the coordinate located at the geometric center of the geo shape.

Note: Getter function for property center.

This function was introduced in Qt 5.5.

[invokable] bool QGeoShape::contains(const QGeoCoordinate &coordinate) const

Returns whether the coordinate coordinate is contained within this geo shape.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

bool QGeoShape::isEmpty() const

Returns whether this geo shape is empty.

An empty geo shape is a region which has a geometrical area of 0.

Note: Getter function for property isEmpty.

bool QGeoShape::isValid() const

Returns whether this geo shape is valid.

Note: Getter function for property isValid.

[invokable, since 5.5] QString QGeoShape::toString() const

Returns a string representation of this geo shape.

Note: This function can be invoked via the meta-object system and from QML. See Q_INVOKABLE.

This function was introduced in Qt 5.5.

QGeoShape::ShapeType QGeoShape::type() const

Returns the type of this geo shape.

Note: Getter function for property type.

Related Non-Members

size_t qHash(const QGeoShape &shape, size_t seed = 0)

Returns the hash value for the shape, using seed for the calculation.

bool operator!=(const QGeoShape &lhs, const QGeoShape &rhs)

Returns true if the lhs geo shape is not equivalent to the rhs geo shape, otherwise returns false.

bool operator==(const QGeoShape &lhs, const QGeoShape &rhs)

Returns true if the lhs geo shape is equivalent to the rhs geo shape, otherwise returns false.

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