QGIS API Documentation 3.41.0-Master (25ec5511245)
Loading...
Searching...
No Matches
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, 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

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.

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

◆ QgsLayoutSize() [2/3]

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

Constructor for QgsLayoutSize.

Definition at line 33 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 40 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 61 of file qgslayoutsize.cpp.

◆ encodeSize()

QString QgsLayoutSize::encodeSize ( ) const

Encodes the layout size to a string.

See also
decodeSize()

Definition at line 56 of file qgslayoutsize.cpp.

◆ height()

double QgsLayoutSize::height ( ) const
inline

Returns the height of the size.

See also
setHeight()
width()

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

◆ operator!=()

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

Definition at line 82 of file qgslayoutsize.cpp.

◆ operator*()

QgsLayoutSize QgsLayoutSize::operator* ( double  v) const

Multiplies the width and height by a scalar value.

Definition at line 87 of file qgslayoutsize.cpp.

◆ operator*=()

QgsLayoutSize QgsLayoutSize::operator*= ( double  v)

Multiplies the width and height by a scalar value.

Definition at line 92 of file qgslayoutsize.cpp.

◆ operator/()

QgsLayoutSize QgsLayoutSize::operator/ ( double  v) const

Divides the width and height by a scalar value.

Definition at line 98 of file qgslayoutsize.cpp.

◆ operator/=()

QgsLayoutSize QgsLayoutSize::operator/= ( double  v)

Divides the width and height by a scalar value.

Definition at line 103 of file qgslayoutsize.cpp.

◆ operator==()

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

Definition at line 77 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 110 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 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 129 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 90 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 51 of file qgslayoutsize.cpp.

◆ units()

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

Returns the units for the size.

See also
setUnits()

Definition at line 122 of file qgslayoutsize.h.

◆ width()

double QgsLayoutSize::width ( ) const
inline

Returns the width of the size.

See also
setWidth()
height()

Definition at line 83 of file qgslayoutsize.h.


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