Class: QgsLayoutPoint

class qgis.core.QgsLayoutPoint(x: float, y: float, units: QgsUnitTypes.LayoutUnit = QgsUnitTypes.LayoutMillimeters)

Bases: sip.wrapper

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)

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 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: Enums

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.

Signals

Attributes

decodePoint(string: str) → QgsLayoutPoint

Decodes a point from a string.

See also

encodePoint()

encodePoint(self) → str

Encodes the layout point to a string

See also

decodePoint()

isNull(self) → bool

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

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()

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()

setX(self, x: float)

Sets the x coordinate of point.

See also

x

See also

setY()

setY(self, y: float)

Sets y coordinate of point.

See also

y

See also

setX()

toQPointF(self) → QPointF

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

Returns:QPointF with same x and y coordinates as layout point
units(self) → QgsUnitTypes.LayoutUnit

Returns the units for the point.

See also

setUnits()

x(self) → float

Returns x coordinate of point.

See also

setX()

See also

y

y(self) → float

Returns y coordinate of point.

See also

setY()

See also

x