Class: QgsLayoutPoint

class qgis.core.QgsLayoutPoint

Bases: sip.wrapper

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.

Note

This class does not inherit from QPointF since QPointF includes methods which should not apply to positions with units. For instance, the + and - operators would mislead users of this class to believe that addition of two QgsLayoutPoints with different unit types would automatically convert units. Instead, all unit conversion must be handled by a QgsLayoutMeasurementConverter so that conversion between paper and screen units can be correctly performed.

New in version 3.0.

QgsLayoutPoint(x: float, y: float, units: QgsUnitTypes.LayoutUnit = QgsUnitTypes.LayoutMillimeters) Constructor for QgsLayoutPoint.

QgsLayoutPoint(point: Union[QPointF, QPoint], units: QgsUnitTypes.LayoutUnit = QgsUnitTypes.LayoutMillimeters) Constructor for QgsLayoutPoint.

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

Parameters:

units – units for measurement

QgsLayoutPoint(QgsLayoutPoint)

Methods

decodePoint

Decodes a point from a string.

encodePoint

Encodes the layout point to a string

isNull

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

setPoint

Sets new x and y coordinates for the point.

setUnits

Sets the units for the point.

setX

Sets the x coordinate of point.

setY

Sets y coordinate of point.

toQPointF

Converts the layout point to a QPointF.

units

Returns the units for the point.

x

Returns x coordinate of point.

y

Returns y coordinate of point.

decodePoint(string: str) QgsLayoutPoint

Decodes a point from a string.

See also

encodePoint()

Parameters:

string (str) –

Return type:

QgsLayoutPoint

encodePoint(self) str

Encodes the layout point to a string

See also

decodePoint()

Return type:

str

isNull(self) bool

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

Return type:

bool

Returns:

True if point is null

setPoint(self, x: float, y: float)

Sets new x and y coordinates for the point.

See also

setX()

See also

setY()

See also

setUnits()

Parameters:
  • x (float) –

  • y (float) –

setUnits(self, units: QgsUnitTypes.LayoutUnit)

Sets the units for the point. Does not alter the stored coordinates, ie. no conversion is done.

See also

units()

Parameters:

units (QgsUnitTypes.LayoutUnit) –

setX(self, x: float)

Sets the x coordinate of point.

See also

x

See also

setY()

Parameters:

x (float) –

setY(self, y: float)

Sets y coordinate of point.

See also

y

See also

setX()

Parameters:

y (float) –

toQPointF(self) QPointF

Converts the layout point to a QPointF. The unit information is discarded during this operation.

Return type:

QPointF

Returns:

QPointF with same x and y coordinates as layout point

units(self) QgsUnitTypes.LayoutUnit

Returns the units for the point.

See also

setUnits()

Return type:

QgsUnitTypes.LayoutUnit

x(self) float

Returns x coordinate of point.

See also

setX()

See also

y

Return type:

float

y(self) float

Returns y coordinate of point.

See also

setY()

See also

x

Return type:

float