QGIS API Documentation  3.4.3-Madeira (2f64a3c)
Public Member Functions | Static Public Member Functions | List of all members
QgsLayoutSize Class Reference

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

Static Public Member Functions

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

Detailed Description

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
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.
Since
QGIS 3.0

Definition at line 40 of file qgslayoutsize.h.

Constructor & Destructor Documentation

◆ QgsLayoutSize() [1/3]

QgsLayoutSize::QgsLayoutSize ( double  width,
double  height,
QgsUnitTypes::LayoutUnit  units = QgsUnitTypes::LayoutMillimeters 
)

Constructor for QgsLayoutSize.

Parameters
widthwidth
heightheight
unitsunits for width and height

Definition at line 22 of file qgslayoutsize.cpp.

◆ QgsLayoutSize() [2/3]

QgsLayoutSize::QgsLayoutSize ( QSizeF  size,
QgsUnitTypes::LayoutUnit  units = QgsUnitTypes::LayoutMillimeters 
)
explicit

Constructor for QgsLayoutSize.

Definition at line 29 of file qgslayoutsize.cpp.

◆ QgsLayoutSize() [3/3]

QgsLayoutSize::QgsLayoutSize ( QgsUnitTypes::LayoutUnit  units = QgsUnitTypes::LayoutMillimeters)
explicit

Constructor for an empty layout size.

Parameters
unitsunits for measurement

Definition at line 36 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 57 of file qgslayoutsize.cpp.

◆ encodeSize()

QString QgsLayoutSize::encodeSize ( ) const

Encodes the layout size to a string.

See also
decodeSize()

Definition at line 52 of file qgslayoutsize.cpp.

◆ height()

double QgsLayoutSize::height ( ) const
inline

Returns the height of the size.

See also
setHeight()
width()

Definition at line 90 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 42 of file qgslayoutsize.cpp.

◆ operator!=()

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

Definition at line 73 of file qgslayoutsize.cpp.

◆ operator*()

QgsLayoutSize QgsLayoutSize::operator* ( double  v) const

Multiplies the width and height by a scalar value.

Definition at line 78 of file qgslayoutsize.cpp.

◆ operator*=()

QgsLayoutSize QgsLayoutSize::operator*= ( double  v)

Multiplies the width and height by a scalar value.

Definition at line 83 of file qgslayoutsize.cpp.

◆ operator/()

QgsLayoutSize QgsLayoutSize::operator/ ( double  v) const

Divides the width and height by a scalar value.

Definition at line 89 of file qgslayoutsize.cpp.

◆ operator/=()

QgsLayoutSize QgsLayoutSize::operator/= ( double  v)

Divides the width and height by a scalar value.

Definition at line 94 of file qgslayoutsize.cpp.

◆ operator==()

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

Definition at line 68 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 97 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 69 of file qgslayoutsize.h.

◆ setUnits()

void QgsLayoutSize::setUnits ( const QgsUnitTypes::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 110 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 83 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 47 of file qgslayoutsize.cpp.

◆ units()

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

Returns the units for the size.

See also
setUnits()

Definition at line 103 of file qgslayoutsize.h.

◆ width()

double QgsLayoutSize::width ( ) const
inline

Returns the width of the size.

See also
setWidth()
height()

Definition at line 76 of file qgslayoutsize.h.


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