Class: QgsLayoutSize¶
Provides a method of storing sizes, consisting of a width and height, for use in QGIS layouts.
Measurement units are stored alongside the size.
See also
Note
This class does not inherit from QSizeF since QSizeF includes methods which should not apply to sizes
with units. For instance, the + and - operators would mislead users of this class to believe that
addition of two QgsLayoutSize 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.
- class qgis.core.QgsLayoutSize[source]¶
Bases:
object- __init__(width: float, height: float, units: Qgis.LayoutUnit = Qgis.LayoutUnit.Millimeters)
Constructor for QgsLayoutSize.
- Parameters:
width (float) – width
height (float) – height
units (Qgis.LayoutUnit = Qgis.LayoutUnit.Millimeters) – units for width and height
- __init__(size: QSizeF, units: Qgis.LayoutUnit = Qgis.LayoutUnit.Millimeters)
Constructor for QgsLayoutSize.
- Parameters:
size (QSizeF)
units (Qgis.LayoutUnit = Qgis.LayoutUnit.Millimeters)
- __init__(units: Qgis.LayoutUnit = Qgis.LayoutUnit.Millimeters)
Constructor for an empty layout size
- Parameters:
units (Qgis.LayoutUnit = Qgis.LayoutUnit.Millimeters) – units for measurement
- __init__(a0: QgsLayoutSize)
- Parameters:
a0 (QgsLayoutSize)
- static decodeSize(string: str | None) QgsLayoutSize[source]¶
Decodes a size from a
string.See also
- Parameters:
string (Optional[str])
- Return type:
- isEmpty(self) bool[source]¶
Tests whether the size is empty, ie both its width and height are zero.
- Return type:
bool
- Returns:
Trueif size is empty
- setHeight(self, height: float)[source]¶
Sets the
heightfor the size.See also
See also
- Parameters:
height (float)
- setSize(self, width: float, height: float)[source]¶
Sets new
widthandheightfor the size.See also
See also
See also
- Parameters:
width (float)
height (float)
- setUnits(self, units: Qgis.LayoutUnit)[source]¶
Sets the
unitsfor the size. Does not alter the stored width or height, ie. no conversion is done.See also
- Parameters:
units (Qgis.LayoutUnit)
- setWidth(self, width: float)[source]¶
Sets the
widthfor the size.See also
See also
- Parameters:
width (float)
- toQSizeF(self) QSizeF[source]¶
Converts the layout size to a QSizeF. The unit information is discarded during this operation.
- Return type:
QSizeF
- Returns:
QSizeF with same dimensions as layout size
- units(self) Qgis.LayoutUnit[source]¶
Returns the units for the size.
See also
- Return type: