Class: QgsLayoutSize¶
- class qgis.core.QgsLayoutSize¶
Bases:
sip.wrapper
This class 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 aQgsLayoutMeasurementConverter
so that conversion between paper and screen units can be correctly performed.New in version 3.0.
QgsLayoutSize(width: float, height: float, units: Qgis.LayoutUnit = Qgis.LayoutUnit.Millimeters) Constructor for QgsLayoutSize.
- Parameters:
width – width
height – height
units – units for width and height
QgsLayoutSize(size: QSizeF, units: Qgis.LayoutUnit = Qgis.LayoutUnit.Millimeters) Constructor for QgsLayoutSize.
QgsLayoutSize(units: Qgis.LayoutUnit = Qgis.LayoutUnit.Millimeters) Constructor for an empty layout size
- Parameters:
units – units for measurement
QgsLayoutSize(
QgsLayoutSize
)Methods
Decodes a size from a
string
.Encodes the layout size to a string
Returns the height of the size.
Tests whether the size is empty, ie both its width and height are zero.
Sets the
height
for the size.Sets new
width
andheight
for the size.Sets the
units
for the size.Sets the
width
for the size.Converts the layout size to a QSizeF.
Returns the units for the size.
Returns the width of the size.
- decodeSize(string: str) QgsLayoutSize ¶
Decodes a size from a
string
.See also
- Parameters:
string (str) –
- Return type:
- encodeSize(self) str ¶
Encodes the layout size to a string
See also
- Return type:
str
- height(self) float ¶
Returns the height of the size.
See also
See also
- Return type:
float
- isEmpty(self) bool ¶
Tests whether the size is empty, ie both its width and height are zero.
- Return type:
bool
- Returns:
True
if size is empty
- setHeight(self, height: float)¶
Sets the
height
for the size.See also
See also
- Parameters:
height (float) –
- setSize(self, width: float, height: float)¶
Sets new
width
andheight
for the size.See also
See also
See also
- Parameters:
width (float) –
height (float) –
- setUnits(self, units: Qgis.LayoutUnit)¶
Sets the
units
for 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)¶
Sets the
width
for the size.See also
See also
- Parameters:
width (float) –
- toQSizeF(self) QSizeF ¶
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 ¶
Returns the units for the size.
See also
- Return type:
- width(self) float ¶
Returns the width of the size.
See also
See also
- Return type:
float