QMarginsF Class

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

Header: #include <QMarginsF>
CMake: find_package(Qt6 REQUIRED COMPONENTS Core)
target_link_libraries(mytarget PRIVATE Qt6::Core)
qmake: QT += core

Public Functions

QMarginsF()
QMarginsF(qreal left, qreal top, qreal right, qreal bottom)
QMarginsF(const QMargins &margins)
qreal bottom() const
bool isNull() const
qreal left() const
qreal right() const
void setBottom(qreal abottom)
void setLeft(qreal aleft)
void setRight(qreal aright)
void setTop(qreal atop)
QMargins toMargins() const
qreal top() const
QMarginsF &operator*=(qreal factor)
QMarginsF &operator+=(const QMarginsF &margins)
QMarginsF &operator+=(qreal addend)
QMarginsF &operator-=(const QMarginsF &margins)
QMarginsF &operator-=(qreal subtrahend)
QMarginsF &operator/=(qreal divisor)
bool operator!=(const QMarginsF &lhs, const QMarginsF &rhs)
QMarginsF operator*(const QMarginsF &lhs, qreal rhs)
QMarginsF operator*(qreal lhs, const QMarginsF &rhs)
QMarginsF operator+(const QMarginsF &lhs, const QMarginsF &rhs)
QMarginsF operator+(const QMarginsF &lhs, qreal rhs)
QMarginsF operator+(qreal lhs, const QMarginsF &rhs)
QMarginsF operator+(const QMarginsF &margins)
QMarginsF operator-(const QMarginsF &lhs, const QMarginsF &rhs)
QMarginsF operator-(const QMarginsF &lhs, qreal rhs)
QMarginsF operator-(const QMarginsF &margins)
QMarginsF operator/(const QMarginsF &lhs, qreal rhs)
QDataStream &operator<<(QDataStream &stream, const QMarginsF &m)
bool operator==(const QMarginsF &lhs, const QMarginsF &rhs)
QDataStream &operator>>(QDataStream &stream, QMarginsF &m)
(since 6.0) QMarginsF operator|(const QMarginsF &m1, const QMarginsF &m2)

Detailed Description

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

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

QMarginsF objects can be streamed as well as compared.

Member Function Documentation

[constexpr noexcept] QMarginsF::QMarginsF()

Constructs a margins object with all margins set to 0.

See also isNull().

[constexpr noexcept] QMarginsF::QMarginsF(qreal left, qreal top, qreal right, qreal bottom)

Constructs margins with the given left, top, right, and bottom. All parameters must be finite.

See also setLeft(), setRight(), setTop(), and setBottom().

[constexpr noexcept] QMarginsF::QMarginsF(const QMargins &margins)

Constructs margins copied from the given margins.

See also QMargins::toMarginsF().

[constexpr noexcept] qreal QMarginsF::bottom() const

Returns the bottom margin.

See also setBottom().

[constexpr noexcept] bool QMarginsF::isNull() const

Returns true if all margins are very close to 0; otherwise returns false.

See also qFuzzyIsNull().

[constexpr noexcept] qreal QMarginsF::left() const

Returns the left margin.

See also setLeft().

Returns the right margin.

See also setRight().

[constexpr noexcept] void QMarginsF::setBottom(qreal abottom)

Sets the bottom margin to abottom (which must be finite).

See also bottom().

[constexpr noexcept] void QMarginsF::setLeft(qreal aleft)

Sets the left margin to aleft (which must be finite).

See also left().

[constexpr noexcept] void QMarginsF::setRight(qreal aright)

Sets the right margin to aright (which must be finite).

See also right().

[constexpr noexcept] void QMarginsF::setTop(qreal atop)

Sets the top margin to atop (which must be finite).

See also top().

[constexpr noexcept] QMargins QMarginsF::toMargins() const

Returns an integer-based copy of this margins object.

Note that the components in the returned margins will be rounded to the nearest integer.

See also QMarginsF() and QMargins::toMarginsF().

[constexpr noexcept] qreal QMarginsF::top() const

Returns the top margin.

See also setTop().

[constexpr noexcept] QMarginsF &QMarginsF::operator*=(qreal factor)

Multiplies each component of this object by the given finite factor and returns a reference to this object.

See also operator/=().

[constexpr noexcept] QMarginsF &QMarginsF::operator+=(const QMarginsF &margins)

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

See also operator-=().

[constexpr noexcept] QMarginsF &QMarginsF::operator+=(qreal addend)

This is an overloaded function.

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

See also operator-=().

[constexpr noexcept] QMarginsF &QMarginsF::operator-=(const QMarginsF &margins)

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

See also operator+=().

[constexpr noexcept] QMarginsF &QMarginsF::operator-=(qreal subtrahend)

This is an overloaded function.

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

See also operator+=().

[constexpr] QMarginsF &QMarginsF::operator/=(qreal divisor)

Divides each component of this object by divisor and returns a reference to this object.

The divisor must not be either zero or NaN.

See also operator*=().

Related Non-Members

[constexpr noexcept] bool operator!=(const QMarginsF &lhs, const QMarginsF &rhs)

Returns true if lhs and rhs are sufficiently different; otherwise returns false.

Warning: This function does not check for strict inequality; instead, it uses a fuzzy comparison to compare the margins.

See also qFuzzyCompare.

[constexpr noexcept] QMarginsF operator*(const QMarginsF &lhs, qreal rhs)

This is an overloaded function.

Returns a QMarginsF object that is formed by multiplying each component of the given lhs margins by finite factor rhs.

See also QMarginsF::operator*=() and QMarginsF::operator/=().

[constexpr noexcept] QMarginsF operator*(qreal lhs, const QMarginsF &rhs)

This is an overloaded function.

Returns a QMarginsF object that is formed by multiplying each component of the given lhs margins by finite factor rhs.

See also QMarginsF::operator*=() and QMarginsF::operator/=().

[constexpr noexcept] QMarginsF operator+(const QMarginsF &lhs, const QMarginsF &rhs)

Returns a QMarginsF object that is the sum of the given margins, lhs and rhs; each component is added separately.

See also QMarginsF::operator+=() and QMarginsF::operator-=().

[constexpr noexcept] QMarginsF operator+(const QMarginsF &lhs, qreal rhs)

Returns a QMarginsF object that is formed by adding rhs (which must be finite) to each component of lhs.

See also QMarginsF::operator+=() and QMarginsF::operator-=().

[constexpr noexcept] QMarginsF operator+(qreal lhs, const QMarginsF &rhs)

Returns a QMarginsF object that is formed by adding lhs (which must be finite) to each component of rhs.

See also QMarginsF::operator+=() and QMarginsF::operator-=().

[constexpr noexcept] QMarginsF operator+(const QMarginsF &margins)

Returns a QMargin object that is formed from all components of margins.

[constexpr noexcept] QMarginsF operator-(const QMarginsF &lhs, const QMarginsF &rhs)

Returns a QMarginsF object that is formed by subtracting rhs from lhs; each component is subtracted separately.

See also QMarginsF::operator+=() and QMarginsF::operator-=().

[constexpr noexcept] QMarginsF operator-(const QMarginsF &lhs, qreal rhs)

Returns a QMarginsF object that is formed by subtracting rhs (which must be finite) from each component of lhs.

See also QMarginsF::operator+=() and QMarginsF::operator-=().

[constexpr noexcept] QMarginsF operator-(const QMarginsF &margins)

Returns a QMargin object that is formed by negating all components of margins.

[constexpr] QMarginsF operator/(const QMarginsF &lhs, qreal rhs)

This is an overloaded function.

Returns a QMarginsF object that is formed by dividing the components of the given lhs margins by the given rhs divisor.

The divisor must not be either zero or NaN.

See also QMarginsF::operator*=() and QMarginsF::operator/=().

QDataStream &operator<<(QDataStream &stream, const QMarginsF &m)

Writes margin m to the given stream and returns a reference to the stream.

See also Serializing Qt Data Types.

[constexpr noexcept] bool operator==(const QMarginsF &lhs, const QMarginsF &rhs)

Returns true if lhs and rhs are approximately equal; otherwise returns false.

Warning: This function does not check for strict equality; instead, it uses a fuzzy comparison to compare the margins.

See also qFuzzyCompare.

QDataStream &operator>>(QDataStream &stream, QMarginsF &m)

Reads a margin from the given stream into margin m and returns a reference to the stream.

See also Serializing Qt Data Types.

[constexpr noexcept, since 6.0] QMarginsF operator|(const QMarginsF &m1, const QMarginsF &m2)

This is an overloaded function.

Returns a QMarginsF object that is formed from the maximum of each component of m2 and m1.

This function was introduced in Qt 6.0.

See also QMarginsF::operator+=() and QMarginsF::operator-=().

© 2024 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.