Class: QgsLayoutMeasurement

Provides a method of storing measurements for use in QGIS layouts using a variety of different measurement units.

class qgis.core.QgsLayoutMeasurement[source]

Bases: object

__init__(length: float, units: Qgis.LayoutUnit = Qgis.LayoutUnit.Millimeters)

Constructor for QgsLayoutMeasurement.

Parameters:
  • length (float) – measurement length

  • units (Qgis.LayoutUnit = Qgis.LayoutUnit.Millimeters) – measurement units

__init__(a0: QgsLayoutMeasurement)
Parameters:

a0 (QgsLayoutMeasurement)

static decodeMeasurement(string: str | None) QgsLayoutMeasurement[source]

Decodes a measurement from a string.

Parameters:

string (Optional[str])

Return type:

QgsLayoutMeasurement

encodeMeasurement(self) str[source]

Encodes the layout measurement to a string

Return type:

str

length(self) float[source]

Returns the length of the measurement.

See also

setLength()

Return type:

float

setLength(self, length: float)[source]

Sets the length of the measurement.

See also

length()

Parameters:

length (float)

setUnits(self, units: Qgis.LayoutUnit)[source]

Sets the units for the measurement. Does not alter the stored length, ie. no length conversion is done.

See also

units()

Parameters:

units (Qgis.LayoutUnit)

units(self) Qgis.LayoutUnit[source]

Returns the units for the measurement.

See also

setUnits()

Return type:

Qgis.LayoutUnit