QgsLayoutSize class
This class provides a method of storing sizes, consisting of a width and height, for use in QGIS layouts.
Contents
Measurement units are stored alongside the size.
Public static functions
- static auto decodeSize(const QString& string) -> QgsLayoutSize
- Decodes a size from a string.
Constructors, destructors, conversion operators
-
QgsLayoutSize(double width,
double height,
QgsUnitTypes::
LayoutUnit units = QgsUnitTypes:: LayoutMillimeters) - Constructor for QgsLayoutSize.
-
QgsLayoutSize(QSizeF size,
QgsUnitTypes::
LayoutUnit units = QgsUnitTypes:: LayoutMillimeters) explicit - Constructor for QgsLayoutSize.
-
QgsLayoutSize(QgsUnitTypes::
LayoutUnit units = QgsUnitTypes:: LayoutMillimeters) explicit - Constructor for an empty layout size.
Public functions
- auto encodeSize() const -> QString
- Encodes the layout size to a string.
- auto height() const -> double
- Returns the height of the size.
- auto isEmpty() const -> bool
- Tests whether the size is empty, ie both its width and height are zero.
- auto operator*(double v) const -> QgsLayoutSize
- Multiplies the width and height by a scalar value.
- auto operator*=(double v) -> QgsLayoutSize
- Multiplies the width and height by a scalar value.
- auto operator/(double v) const -> QgsLayoutSize
- Divides the width and height by a scalar value.
- auto operator/=(double v) -> QgsLayoutSize
- Divides the width and height by a scalar value.
- void setHeight(const double height)
- Sets the height for the size.
- void setSize(const double width, const double height)
- Sets new width and height for the size.
-
void setUnits(const QgsUnitTypes::
LayoutUnit units) - Sets the units for the size.
- void setWidth(const double width)
- Sets the width for the size.
- auto toQSizeF() const -> QSizeF
- Converts the layout size to a QSizeF.
-
auto units() const -> QgsUnitTypes::
LayoutUnit - Returns the units for the size.
- auto width() const -> double
- Returns the width of the size.
Function documentation
static QgsLayoutSize QgsLayoutSize:: decodeSize(const QString& string)
Decodes a size from a string.
QgsLayoutSize:: QgsLayoutSize(double width,
double height,
QgsUnitTypes:: LayoutUnit units = QgsUnitTypes:: LayoutMillimeters)
Constructor for QgsLayoutSize.
| Parameters | |
|---|---|
| width | width |
| height | height |
| units | units for width and height |
QgsLayoutSize:: QgsLayoutSize(QgsUnitTypes:: LayoutUnit units = QgsUnitTypes:: LayoutMillimeters) explicit
Constructor for an empty layout size.
| Parameters | |
|---|---|
| units | units for measurement |
QString QgsLayoutSize:: encodeSize() const
Encodes the layout size to a string.
double QgsLayoutSize:: height() const
Returns the height of the size.
bool QgsLayoutSize:: isEmpty() const
Tests whether the size is empty, ie both its width and height are zero.
| Returns | true if size is empty |
|---|
void QgsLayoutSize:: setHeight(const double height)
Sets the height for the size.
void QgsLayoutSize:: setSize(const double width,
const double height)
Sets new width and height for the size.
void QgsLayoutSize:: setUnits(const QgsUnitTypes:: LayoutUnit units)
Sets the units for the size.
Does not alter the stored width or height, ie. no conversion is done.
void QgsLayoutSize:: setWidth(const double width)
Sets the width for the size.
QSizeF QgsLayoutSize:: toQSizeF() const
Converts the layout size to a QSizeF.
| Returns | QSizeF with same dimensions as layout size |
|---|
The unit information is discarded during this operation.
QgsUnitTypes:: LayoutUnit QgsLayoutSize:: units() const
Returns the units for the size.
double QgsLayoutSize:: width() const
Returns the width of the size.