QGIS API Documentation  3.18.1-Zürich (202f1bf7e5)
Public Member Functions | Static Public Member Functions | List of all members
QgsMargins Class Reference

The QgsMargins class defines the four margins of a rectangle. More...

#include <qgsmargins.h>

Public Member Functions

 QgsMargins ()=default
 Constructs a margins object with all margins set to 0. More...
 
 QgsMargins (double left, double top, double right, double bottom)
 Constructs margins with the given left, top, right, bottom. More...
 
double bottom () const
 Returns the bottom margin. More...
 
bool isNull () const
 Returns true if all margins are is 0; otherwise returns false. More...
 
double left () const
 Returns the left margin. More...
 
QgsMarginsoperator*= (double factor)
 Multiplies each component of this object by factor and returns a reference to it. More...
 
QgsMarginsoperator+= (const QgsMargins &margins)
 Add each component of margins to the respective component of this object and returns a reference to it. More...
 
QgsMarginsoperator+= (double addend)
 Adds the addend to each component of this object and returns a reference to it. More...
 
QgsMarginsoperator-= (const QgsMargins &margins)
 Subtract each component of margins from the respective component of this object and returns a reference to it. More...
 
QgsMarginsoperator-= (double subtrahend)
 Subtracts the subtrahend from each component of this object and returns a reference to it. More...
 
QgsMarginsoperator/= (double divisor)
 Multiplies each component of this object by factor and returns a reference to it. More...
 
double right () const
 Returns the right margin. More...
 
void setBottom (double bottom)
 Sets the bottom margin to bottom. More...
 
void setLeft (double left)
 Sets the left margin to left. More...
 
void setRight (double right)
 Sets the right margin to right. More...
 
void setTop (double top)
 Sets the top margin to top. More...
 
double top () const
 Returns the top margin. More...
 
QString toString () const
 Returns the margins encoded to a string. More...
 

Static Public Member Functions

static QgsMargins fromString (const QString &string)
 Returns a QgsMargins object decoded from a string, or a null QgsMargins if the string could not be interpreted as margins. More...
 

Detailed Description

The QgsMargins class defines the four margins of a rectangle.

QgsMargins defines a set of four margins; left, top, right and bottom, that describe the size of the borders surrounding a rectangle.

The isNull() function returns true only if all margins are set to zero.

Since
QGIS 3.0

Definition at line 37 of file qgsmargins.h.

Constructor & Destructor Documentation

◆ QgsMargins() [1/2]

QgsMargins::QgsMargins ( )
default

Constructs a margins object with all margins set to 0.

◆ QgsMargins() [2/2]

QgsMargins::QgsMargins ( double  left,
double  top,
double  right,
double  bottom 
)
inline

Constructs margins with the given left, top, right, bottom.

See also
setLeft()
setRight()
setTop()
setBottom()

Definition at line 53 of file qgsmargins.h.

Member Function Documentation

◆ bottom()

double QgsMargins::bottom ( ) const
inline

Returns the bottom margin.

See also
setBottom()

Definition at line 90 of file qgsmargins.h.

◆ fromString()

QgsMargins QgsMargins::fromString ( const QString &  string)
static

Returns a QgsMargins object decoded from a string, or a null QgsMargins if the string could not be interpreted as margins.

See also
toString()

Definition at line 27 of file qgsmargins.cpp.

◆ isNull()

bool QgsMargins::isNull ( ) const
inline

Returns true if all margins are is 0; otherwise returns false.

Definition at line 63 of file qgsmargins.h.

◆ left()

double QgsMargins::left ( ) const
inline

Returns the left margin.

See also
setLeft()

Definition at line 72 of file qgsmargins.h.

◆ operator*=()

QgsMargins & QgsMargins::operator*= ( double  factor)
inline

Multiplies each component of this object by factor and returns a reference to it.

Definition at line 296 of file qgsmargins.h.

◆ operator+=() [1/2]

QgsMargins & QgsMargins::operator+= ( const QgsMargins margins)
inline

Add each component of margins to the respective component of this object and returns a reference to it.

Definition at line 268 of file qgsmargins.h.

◆ operator+=() [2/2]

QgsMargins & QgsMargins::operator+= ( double  addend)
inline

Adds the addend to each component of this object and returns a reference to it.

Definition at line 278 of file qgsmargins.h.

◆ operator-=() [1/2]

QgsMargins & QgsMargins::operator-= ( const QgsMargins margins)
inline

Subtract each component of margins from the respective component of this object and returns a reference to it.

Definition at line 273 of file qgsmargins.h.

◆ operator-=() [2/2]

QgsMargins & QgsMargins::operator-= ( double  subtrahend)
inline

Subtracts the subtrahend from each component of this object and returns a reference to it.

Definition at line 287 of file qgsmargins.h.

◆ operator/=()

QgsMargins & QgsMargins::operator/= ( double  divisor)
inline

Multiplies each component of this object by factor and returns a reference to it.

Definition at line 301 of file qgsmargins.h.

◆ right()

double QgsMargins::right ( ) const
inline

Returns the right margin.

See also
setRight()

Definition at line 84 of file qgsmargins.h.

◆ setBottom()

void QgsMargins::setBottom ( double  bottom)
inline

Sets the bottom margin to bottom.

See also
bottom()

Definition at line 114 of file qgsmargins.h.

◆ setLeft()

void QgsMargins::setLeft ( double  left)
inline

Sets the left margin to left.

See also
left()

Definition at line 96 of file qgsmargins.h.

◆ setRight()

void QgsMargins::setRight ( double  right)
inline

Sets the right margin to right.

See also
right()

Definition at line 108 of file qgsmargins.h.

◆ setTop()

void QgsMargins::setTop ( double  top)
inline

Sets the top margin to top.

See also
top()

Definition at line 102 of file qgsmargins.h.

◆ top()

double QgsMargins::top ( ) const
inline

Returns the top margin.

See also
setTop()

Definition at line 78 of file qgsmargins.h.

◆ toString()

QString QgsMargins::toString ( ) const

Returns the margins encoded to a string.

See also
fromString()

Definition at line 18 of file qgsmargins.cpp.


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