QgsLayoutPoint class

This class provides a method of storing points, consisting of an x and y coordinate, for use in QGIS layouts.

Measurement units are stored alongside the position.

Public static functions

static auto decodePoint(const QString& string) -> QgsLayoutPoint
Decodes a point from a string.

Constructors, destructors, conversion operators

QgsLayoutPoint(double x, double y, QgsUnitTypes::LayoutUnit units = QgsUnitTypes::LayoutMillimeters)
Constructor for QgsLayoutPoint.
QgsLayoutPoint(QPointF point, QgsUnitTypes::LayoutUnit units = QgsUnitTypes::LayoutMillimeters) explicit
Constructor for QgsLayoutPoint.
QgsLayoutPoint(QgsUnitTypes::LayoutUnit units = QgsUnitTypes::LayoutMillimeters) explicit
Constructor for an empty point, where both x and y are set to 0.

Public functions

auto encodePoint() const -> QString
Encodes the layout point to a string.
auto isNull() const -> bool
Tests whether the position is null, ie both its x and y coordinates are zero.
auto operator*(double v) const -> QgsLayoutPoint
Multiplies the x and y by a scalar value.
auto operator*=(double v) -> QgsLayoutPoint
Multiplies the x and y by a scalar value.
auto operator/(double v) const -> QgsLayoutPoint
Divides the x and y by a scalar value.
auto operator/=(double v) -> QgsLayoutPoint
Divides the x and y by a scalar value.
void setPoint(const double x, const double y)
Sets new x and y coordinates for the point.
void setUnits(const QgsUnitTypes::LayoutUnit units)
Sets the units for the point.
void setX(const double x)
Sets the x coordinate of point.
void setY(const double y)
Sets y coordinate of point.
auto toQPointF() const -> QPointF
Converts the layout point to a QPointF.
auto units() const -> QgsUnitTypes::LayoutUnit
Returns the units for the point.
auto x() const -> double
Returns x coordinate of point.
auto y() const -> double
Returns y coordinate of point.

Function documentation

static QgsLayoutPoint QgsLayoutPoint::decodePoint(const QString& string)

Decodes a point from a string.

QgsLayoutPoint::QgsLayoutPoint(QgsUnitTypes::LayoutUnit units = QgsUnitTypes::LayoutMillimeters) explicit

Constructor for an empty point, where both x and y are set to 0.

Parameters
units units for measurement

QString QgsLayoutPoint::encodePoint() const

Encodes the layout point to a string.

bool QgsLayoutPoint::isNull() const

Tests whether the position is null, ie both its x and y coordinates are zero.

Returns true if point is null

void QgsLayoutPoint::setPoint(const double x, const double y)

Sets new x and y coordinates for the point.

void QgsLayoutPoint::setUnits(const QgsUnitTypes::LayoutUnit units)

Sets the units for the point.

Does not alter the stored coordinates, ie. no conversion is done.

void QgsLayoutPoint::setX(const double x)

Sets the x coordinate of point.

void QgsLayoutPoint::setY(const double y)

Sets y coordinate of point.

QPointF QgsLayoutPoint::toQPointF() const

Converts the layout point to a QPointF.

Returns QPointF with same x and y coordinates as layout point

The unit information is discarded during this operation.

QgsUnitTypes::LayoutUnit QgsLayoutPoint::units() const

Returns the units for the point.

double QgsLayoutPoint::x() const

Returns x coordinate of point.

double QgsLayoutPoint::y() const

Returns y coordinate of point.