QGIS API Documentation 3.99.0-Master (26c88405ac0)
Loading...
Searching...
No Matches
QgsLayoutSize Class Reference

Provides a method of storing sizes, consisting of a width and height, for use in QGIS layouts. More...

#include <qgslayoutsize.h>

Public Member Functions

 QgsLayoutSize (double width, double height, Qgis::LayoutUnit units=Qgis::LayoutUnit::Millimeters)
 Constructor for QgsLayoutSize.
 QgsLayoutSize (Qgis::LayoutUnit units=Qgis::LayoutUnit::Millimeters)
 Constructor for an empty layout size.
 QgsLayoutSize (QSizeF size, Qgis::LayoutUnit units=Qgis::LayoutUnit::Millimeters)
 Constructor for QgsLayoutSize.
QString encodeSize () const
 Encodes the layout size to a string.
double height () const
 Returns the height of the size.
bool isEmpty () const
 Tests whether the size is empty, ie both its width and height are zero.
bool operator!= (const QgsLayoutSize &other) const
QgsLayoutSize operator* (double v) const
 Multiplies the width and height by a scalar value.
QgsLayoutSize operator*= (double v)
 Multiplies the width and height by a scalar value.
QgsLayoutSize operator/ (double v) const
 Divides the width and height by a scalar value.
QgsLayoutSize operator/= (double v)
 Divides the width and height by a scalar value.
bool operator== (const QgsLayoutSize &other) const
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 Qgis::LayoutUnit units)
 Sets the units for the size.
void setWidth (const double width)
 Sets the width for the size.
QSizeF toQSizeF () const
 Converts the layout size to a QSizeF.
Qgis::LayoutUnit units () const
 Returns the units for the size.
double width () const
 Returns the width of the size.

Static Public Member Functions

static QgsLayoutSize decodeSize (const QString &string)
 Decodes a size from a string.

Detailed Description

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
QgsLayoutMeasurementConverter
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.

Definition at line 43 of file qgslayoutsize.h.

Constructor & Destructor Documentation

◆ QgsLayoutSize() [1/3]

QgsLayoutSize::QgsLayoutSize ( double width,
double height,
Qgis::LayoutUnit units = Qgis::LayoutUnit::Millimeters )

Constructor for QgsLayoutSize.

Parameters
widthwidth
heightheight
unitsunits for width and height

Definition at line 25 of file qgslayoutsize.cpp.

◆ QgsLayoutSize() [2/3]

QgsLayoutSize::QgsLayoutSize ( QSizeF size,
Qgis::LayoutUnit units = Qgis::LayoutUnit::Millimeters )
explicit

Constructor for QgsLayoutSize.

Definition at line 35 of file qgslayoutsize.cpp.

◆ QgsLayoutSize() [3/3]

QgsLayoutSize::QgsLayoutSize ( Qgis::LayoutUnit units = Qgis::LayoutUnit::Millimeters)
explicit

Constructor for an empty layout size.

Parameters
unitsunits for measurement

Definition at line 42 of file qgslayoutsize.cpp.

Member Function Documentation

◆ decodeSize()

QgsLayoutSize QgsLayoutSize::decodeSize ( const QString & string)
static

Decodes a size from a string.

See also
encodeSize()

Definition at line 63 of file qgslayoutsize.cpp.

◆ encodeSize()

QString QgsLayoutSize::encodeSize ( ) const

Encodes the layout size to a string.

See also
decodeSize()

Definition at line 58 of file qgslayoutsize.cpp.

◆ height()

double QgsLayoutSize::height ( ) const
inline

Returns the height of the size.

See also
setHeight()
width()

Definition at line 106 of file qgslayoutsize.h.

◆ isEmpty()

bool QgsLayoutSize::isEmpty ( ) const

Tests whether the size is empty, ie both its width and height are zero.

Returns
true if size is empty

Definition at line 48 of file qgslayoutsize.cpp.

◆ operator!=()

bool QgsLayoutSize::operator!= ( const QgsLayoutSize & other) const

Definition at line 84 of file qgslayoutsize.cpp.

◆ operator*()

QgsLayoutSize QgsLayoutSize::operator* ( double v) const

Multiplies the width and height by a scalar value.

Definition at line 89 of file qgslayoutsize.cpp.

◆ operator*=()

QgsLayoutSize QgsLayoutSize::operator*= ( double v)

Multiplies the width and height by a scalar value.

Definition at line 94 of file qgslayoutsize.cpp.

◆ operator/()

QgsLayoutSize QgsLayoutSize::operator/ ( double v) const

Divides the width and height by a scalar value.

Definition at line 100 of file qgslayoutsize.cpp.

◆ operator/=()

QgsLayoutSize QgsLayoutSize::operator/= ( double v)

Divides the width and height by a scalar value.

Definition at line 105 of file qgslayoutsize.cpp.

◆ operator==()

bool QgsLayoutSize::operator== ( const QgsLayoutSize & other) const

Definition at line 79 of file qgslayoutsize.cpp.

◆ setHeight()

void QgsLayoutSize::setHeight ( const double height)
inline

Sets the height for the size.

See also
height()
setWidth()

Definition at line 113 of file qgslayoutsize.h.

◆ setSize()

void QgsLayoutSize::setSize ( const double width,
const double height )
inline

Sets new width and height for the size.

See also
setWidth()
setHeight()
setUnits()

Definition at line 72 of file qgslayoutsize.h.

◆ setUnits()

void QgsLayoutSize::setUnits ( const Qgis::LayoutUnit units)
inline

Sets the units for the size.

Does not alter the stored width or height, ie. no conversion is done.

See also
units()

Definition at line 132 of file qgslayoutsize.h.

◆ setWidth()

void QgsLayoutSize::setWidth ( const double width)
inline

Sets the width for the size.

See also
width()
setHeight()

Definition at line 93 of file qgslayoutsize.h.

◆ toQSizeF()

QSizeF QgsLayoutSize::toQSizeF ( ) const

Converts the layout size to a QSizeF.

The unit information is discarded during this operation.

Returns
QSizeF with same dimensions as layout size

Definition at line 53 of file qgslayoutsize.cpp.

◆ units()

Qgis::LayoutUnit QgsLayoutSize::units ( ) const
inline

Returns the units for the size.

See also
setUnits()

Definition at line 125 of file qgslayoutsize.h.

◆ width()

double QgsLayoutSize::width ( ) const
inline

Returns the width of the size.

See also
setWidth()
height()

Definition at line 86 of file qgslayoutsize.h.


The documentation for this class was generated from the following files: