6.0.0-rc4Source

QMargins Class

The QMargins class defines the four margins of a rectangle. More…

Header#include <QMargins>
CMaketarget_link_libraries(app PRIVATE Nt::Core)
ModuleNt Core C++ Classes

List of all members, including inherited members

Public Functions

QMargins()
QMargins(int left, int top, int right, int bottom)
boolisNull() const
intleft() const
inttop() const
intright() const
intbottom() const
voidsetLeft(int v)
voidsetTop(int v)
voidsetRight(int v)
voidsetBottom(int v)
QMargins &operator+=(const QMargins &m)
QMargins &operator-=(const QMargins &m)
QMargins &operator+=(int v)
QMargins &operator-=(int v)
QMargins &operator*=(int f)
QMargins &operator/=(int d)
QMargins &operator*=(double f)
QMargins &operator/=(double d)
QMarginsFtoMarginsF() const

Detailed Description

A margin is the distance between the edge of a rectangle and its contents. QMargins stores the left, top, right and bottom margins as int values. All margins are 0 by default. Use QMarginsF for floating-point margins.

See also QMarginsF and QRect.

Differences from Qt

Division by an integer truncates; division by a double rounds.

Member Function Documentation

[constexpr] QMargins::QMargins()

Constructs margins that are all 0.

See also isNull().

[constexpr] QMargins::QMargins(int left, int top, int right, int bottom)

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

[constexpr] int QMargins::bottom() const

Returns the bottom margin.

See also setBottom().

[constexpr] bool QMargins::isNull() const

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

[constexpr] int QMargins::left() const

Returns the left margin.

See also setLeft().

[constexpr] QMargins & QMargins::operator*=(int f)

Multiplies each margin by the integer factor f and returns a reference to these margins.

QMargins & QMargins::operator*=(double f)

This is an overloaded function.

Multiplies each margin by f, rounds the result to the nearest integer, and returns a reference to these margins.

[constexpr] QMargins & QMargins::operator+=(const QMargins &m)

Adds the margins of m to these margins and returns a reference to these margins.

[constexpr] QMargins & QMargins::operator+=(int v)

This is an overloaded function.

Adds v to each margin and returns a reference to these margins.

[constexpr] QMargins & QMargins::operator-=(const QMargins &m)

Subtracts the margins of m from these margins and returns a reference to these margins.

[constexpr] QMargins & QMargins::operator-=(int v)

This is an overloaded function.

Subtracts v from each margin and returns a reference to these margins.

[constexpr] QMargins & QMargins::operator/=(int d)

Divides each margin by the integer divisor d, truncating the results, and returns a reference to these margins.

QMargins & QMargins::operator/=(double d)

This is an overloaded function.

Divides each margin by d, rounds the result to the nearest integer, and returns a reference to these margins.

Returns the right margin.

See also setRight().

[constexpr] void QMargins::setBottom(int v)

Sets the bottom margin to v.

See also bottom().

[constexpr] void QMargins::setLeft(int v)

Sets the left margin to v.

See also left().

[constexpr] void QMargins::setRight(int v)

Sets the right margin to v.

See also right().

[constexpr] void QMargins::setTop(int v)

Sets the top margin to v.

See also top().

[constexpr] QMarginsF QMargins::toMarginsF() const

Returns these margins as margins with floating point accuracy.

This function was introduced in 6.4.

See also QMarginsF::toMargins().

[constexpr] int QMargins::top() const

Returns the top margin.

See also setTop().