Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
QMarginsF Class Reference

\inmodule QtCore More...

#include <qmargins.h>

+ Collaboration diagram for QMarginsF:

Public Member Functions

constexpr QMarginsF () noexcept
 Constructs a margins object with all margins set to 0.
 
constexpr QMarginsF (qreal left, qreal top, qreal right, qreal bottom) noexcept
 Constructs margins with the given left, top, right, and bottom.
 
constexpr QMarginsF (const QMargins &margins) noexcept
 Constructs margins copied from the given margins.
 
constexpr bool isNull () const noexcept
 Returns true if all margins are very close to 0; otherwise returns false.
 
constexpr qreal left () const noexcept
 Returns the left margin.
 
constexpr qreal top () const noexcept
 Returns the top margin.
 
constexpr qreal right () const noexcept
 Returns the right margin.
 
constexpr qreal bottom () const noexcept
 Returns the bottom margin.
 
constexpr void setLeft (qreal aleft) noexcept
 Sets the left margin to aleft (which must be finite).
 
constexpr void setTop (qreal atop) noexcept
 Sets the top margin to atop (which must be finite).
 
constexpr void setRight (qreal aright) noexcept
 Sets the right margin to aright (which must be finite).
 
constexpr void setBottom (qreal abottom) noexcept
 Sets the bottom margin to abottom (which must be finite).
 
constexpr QMarginsFoperator+= (const QMarginsF &margins) noexcept
 Add each component of margins to the respective component of this object and returns a reference to it.
 
constexpr QMarginsFoperator-= (const QMarginsF &margins) noexcept
 Subtract each component of margins from the respective component of this object and returns a reference to it.
 
constexpr QMarginsFoperator+= (qreal addend) noexcept
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Adds the given finite addend to each component of this object and returns a reference to it.
 
constexpr QMarginsFoperator-= (qreal subtrahend) noexcept
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Subtracts the given finite subtrahend from each component of this object and returns a reference to it.
 
constexpr QMarginsFoperator*= (qreal factor) noexcept
 Multiplies each component of this object by the given finite factor and returns a reference to this object.
 
constexpr QMarginsFoperator/= (qreal divisor)
 Divides each component of this object by divisor and returns a reference to this object.
 
constexpr QMargins toMargins () const noexcept
 Returns an integer-based copy of this margins object.
 

Friends

QT_WARNING_PUSH QT_WARNING_DISABLE_FLOAT_COMPARE friend constexpr bool qFuzzyCompare (const QMarginsF &lhs, const QMarginsF &rhs) noexcept
 
QT_WARNING_POP friend constexpr bool qFuzzyIsNull (const QMarginsF &m) noexcept
 
constexpr bool comparesEqual (const QMarginsF &lhs, const QMarginsF &rhs) noexcept
 
constexpr bool comparesEqual (const QMarginsF &lhs, const QMargins &rhs) noexcept
 
template<std::size_t I, typename M , std::enable_if_t<(I< 4), bool > = true, std::enable_if_t< std::is_same_v< q20::remove_cvref_t< M >, QMarginsF >, bool > = true>
constexpr decltype(auto) get (M &&m) noexcept
 

Related Symbols

(Note that these are not member symbols.)

const 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.
 
const 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.
 
const 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.
 
const 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.
 
const 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.
 
const QMarginsF operator* (const QMarginsF &lhs, qreal rhs)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Returns a QMarginsF object that is formed by multiplying each component of the given lhs margins by finite factor rhs.
 
const QMarginsF operator* (qreal lhs, const QMarginsF &rhs)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Returns a QMarginsF object that is formed by multiplying each component of the given lhs margins by finite factor rhs.
 
const QMarginsF operator/ (const QMarginsF &lhs, qreal rhs)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Returns a QMarginsF object that is formed by dividing the components of the given lhs margins by the given rhs divisor.
 
QMarginsF operator| (const QMarginsF &m1, const QMarginsF &m2)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Returns a QMarginsF object that is formed from the maximum of each component of m2 and m1.
 
QMarginsF operator+ (const QMarginsF &margins)
 Returns a QMargin object that is formed from all components of margins.
 
QMarginsF operator- (const QMarginsF &margins)
 Returns a QMargin object that is formed by negating all components of margins.
 
QDataStreamoperator<< (QDataStream &stream, const QMarginsF &m)
 Writes margin m to the given stream and returns a reference to the stream.
 
QDataStreamoperator>> (QDataStream &stream, QMarginsF &m)
 Reads a margin from the given stream into margin m and returns a reference to the stream.
 

Detailed Description

\inmodule QtCore

Since
5.3

\compares equality \compareswith equality QMargins \endcompareswith

The QMarginsF class defines the four margins of a rectangle.

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.

Definition at line 269 of file qmargins.h.

Constructor & Destructor Documentation

◆ QMarginsF() [1/3]

constexpr QMarginsF::QMarginsF ( )
inlineconstexprnoexcept

Constructs a margins object with all margins set to 0.

See also
isNull()

Definition at line 365 of file qmargins.h.

◆ QMarginsF() [2/3]

constexpr QMarginsF::QMarginsF ( qreal left,
qreal top,
qreal right,
qreal bottom )
inlineconstexprnoexcept

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

All parameters must be finite.

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

Definition at line 368 of file qmargins.h.

◆ QMarginsF() [3/3]

constexpr QMarginsF::QMarginsF ( const QMargins & margins)
inlineconstexprnoexcept

Constructs margins copied from the given margins.

See also
QMargins::toMarginsF()

Definition at line 371 of file qmargins.h.

Member Function Documentation

◆ bottom()

◆ isNull()

constexpr bool QMarginsF::isNull ( ) const
inlineconstexprnoexcept

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

See also
{<QtNumeric>::}{qFuzzyIsNull()}

Definition at line 374 of file qmargins.h.

References qFuzzyIsNull.

Referenced by qt_convertMargins(), QGraphicsWidget::setContentsMargins(), and QGraphicsWidget::setWindowFrameMargins().

+ Here is the caller graph for this function:

◆ left()

◆ operator*=()

constexpr QMarginsF & QMarginsF::operator*= ( qreal factor)
inlineconstexprnoexcept

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

See also
operator/=()

Definition at line 485 of file qmargins.h.

◆ operator+=() [1/2]

constexpr QMarginsF & QMarginsF::operator+= ( const QMarginsF & margins)
inlineconstexprnoexcept

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

See also
operator-=()

Definition at line 457 of file qmargins.h.

◆ operator+=() [2/2]

constexpr QMarginsF & QMarginsF::operator+= ( qreal addend)
inlineconstexprnoexcept

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Adds the given finite addend to each component of this object and returns a reference to it.

See also
operator-=()

Definition at line 467 of file qmargins.h.

◆ operator-=() [1/2]

constexpr QMarginsF & QMarginsF::operator-= ( const QMarginsF & margins)
inlineconstexprnoexcept

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

See also
operator+=()

Definition at line 462 of file qmargins.h.

◆ operator-=() [2/2]

constexpr QMarginsF & QMarginsF::operator-= ( qreal subtrahend)
inlineconstexprnoexcept

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Subtracts the given finite subtrahend from each component of this object and returns a reference to it.

See also
operator+=()

Definition at line 476 of file qmargins.h.

◆ operator/=()

constexpr QMarginsF & QMarginsF::operator/= ( qreal divisor)
inlineconstexpr

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*=()

Definition at line 490 of file qmargins.h.

◆ right()

◆ setBottom()

constexpr void QMarginsF::setBottom ( qreal abottom)
inlineconstexprnoexcept

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

Definition at line 399 of file qmargins.h.

Referenced by QPageLayout::setBottomMargin(), QQuickLayoutAttached::setBottomMargin(), and QPageLayout::setOrientation().

+ Here is the caller graph for this function:

◆ setLeft()

constexpr void QMarginsF::setLeft ( qreal aleft)
inlineconstexprnoexcept

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

Definition at line 390 of file qmargins.h.

Referenced by QTextDocument::print(), QPageLayout::setLeftMargin(), QQuickLayoutAttached::setLeftMargin(), and QPageLayout::setOrientation().

+ Here is the caller graph for this function:

◆ setRight()

constexpr void QMarginsF::setRight ( qreal aright)
inlineconstexprnoexcept

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

Definition at line 396 of file qmargins.h.

Referenced by QPageLayout::setOrientation(), QQuickLayoutAttached::setRightMargin(), and QPageLayout::setRightMargin().

+ Here is the caller graph for this function:

◆ setTop()

constexpr void QMarginsF::setTop ( qreal atop)
inlineconstexprnoexcept

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

Definition at line 393 of file qmargins.h.

Referenced by QPageLayout::setOrientation(), QQuickLayoutAttached::setTopMargin(), and QPageLayout::setTopMargin().

+ Here is the caller graph for this function:

◆ toMargins()

constexpr QMargins QMarginsF::toMargins ( ) const
inlineconstexprnoexcept

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(), QMargins::toMarginsF()

Definition at line 507 of file qmargins.h.

References qRound().

Referenced by QWasmWindow::frameMargins(), QPageLayoutPrivate::marginsPixels(), QPageLayout::marginsPoints(), and QPageLayout::paintRectPoints().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ top()

Friends And Related Symbol Documentation

◆ comparesEqual [1/2]

constexpr bool comparesEqual ( const QMarginsF & lhs,
const QMargins & rhs )
friend

Definition at line 329 of file qmargins.h.

◆ comparesEqual [2/2]

constexpr bool comparesEqual ( const QMarginsF & lhs,
const QMarginsF & rhs )
friend

Definition at line 323 of file qmargins.h.

◆ get

template<std::size_t I, typename M , std::enable_if_t<(I< 4), bool > = true, std::enable_if_t< std::is_same_v< q20::remove_cvref_t< M >, QMarginsF >, bool > = true>
constexpr decltype(auto) get ( M && m)
friend

Definition at line 337 of file qmargins.h.

◆ operator*() [1/2]

const QMarginsF operator* ( const QMarginsF & lhs,
qreal rhs )
related

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Returns a QMarginsF object that is formed by multiplying each component of the given lhs margins by finite factor rhs.

See also
QMarginsF::operator*=(), QMarginsF::operator/=()

Definition at line 432 of file qmargins.h.

◆ operator*() [2/2]

const QMarginsF operator* ( qreal lhs,
const QMarginsF & rhs )
related

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Returns a QMarginsF object that is formed by multiplying each component of the given lhs margins by finite factor rhs.

See also
QMarginsF::operator*=(), QMarginsF::operator/=()

Definition at line 438 of file qmargins.h.

◆ operator+() [1/4]

const QMarginsF operator+ ( const QMarginsF & lhs,
const QMarginsF & rhs )
related

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

See also
QMarginsF::operator+=(), QMarginsF::operator-=()

Definition at line 402 of file qmargins.h.

◆ operator+() [2/4]

const QMarginsF operator+ ( const QMarginsF & lhs,
qreal rhs )
related

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

See also
QMarginsF::operator+=(), QMarginsF::operator-=()

Definition at line 414 of file qmargins.h.

◆ operator+() [3/4]

QMarginsF operator+ ( const QMarginsF & margins)
related

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

Definition at line 495 of file qmargins.h.

◆ operator+() [4/4]

const QMarginsF operator+ ( qreal lhs,
const QMarginsF & rhs )
related

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

See also
QMarginsF::operator+=(), QMarginsF::operator-=()

Definition at line 420 of file qmargins.h.

◆ operator-() [1/3]

const QMarginsF operator- ( const QMarginsF & lhs,
const QMarginsF & rhs )
related

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

See also
QMarginsF::operator+=(), QMarginsF::operator-=()

Definition at line 408 of file qmargins.h.

◆ operator-() [2/3]

const QMarginsF operator- ( const QMarginsF & lhs,
qreal rhs )
related

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

See also
QMarginsF::operator+=(), QMarginsF::operator-=()

Definition at line 426 of file qmargins.h.

◆ operator-() [3/3]

QMarginsF operator- ( const QMarginsF & margins)
related

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

Definition at line 500 of file qmargins.h.

References QMargins::bottom(), QMargins::left(), QMargins::right(), and QMargins::top().

+ Here is the call graph for this function:

◆ operator/()

const QMarginsF operator/ ( const QMarginsF & lhs,
qreal rhs )
related

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.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*=(), QMarginsF::operator/=()

Definition at line 444 of file qmargins.h.

References bottom(), left(), Q_ASSERT, right(), and top().

+ Here is the call graph for this function:

◆ operator<<()

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

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

See also
{Serializing Qt Data Types}

Definition at line 787 of file qmargins.cpp.

◆ operator>>()

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

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

See also
{Serializing Qt Data Types}

Definition at line 803 of file qmargins.cpp.

◆ operator|()

QMarginsF operator| ( const QMarginsF & m1,
const QMarginsF & m2 )
related

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Returns a QMarginsF object that is formed from the maximum of each component of m2 and m1.

See also
QMarginsF::operator+=(), QMarginsF::operator-=()
Since
6.0

Definition at line 451 of file qmargins.h.

References qMax().

+ Here is the call graph for this function:

◆ qFuzzyCompare

bool QMarginsF::qFuzzyCompare ( const QMarginsF & lhs,
const QMarginsF & rhs )
friend
Since
6.8

Returns true if lhs is approximately equal to rhs; otherwise returns false.

Definition at line 305 of file qmargins.h.

◆ qFuzzyIsNull

bool QMarginsF::qFuzzyIsNull ( const QMarginsF & margins)
friend
Since
6.8

Returns true if all components of margsins margins are approximately equal to zero; otherwise returns false.

Definition at line 317 of file qmargins.h.

Referenced by isNull().


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