6.0.0-rc4Source

QSizeF Class

The QSizeF class defines the size of a two-dimensional object using floating point precision. More…

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

List of all members, including inherited members

Public Functions

QSizeF()
QSizeF(const QSize &s)
QSizeF(double w, double h)
boolisNull() const
boolisEmpty() const
boolisValid() const
doublewidth() const
doubleheight() const
voidsetWidth(double w)
voidsetHeight(double h)
double &rwidth()
double &rheight()
voidtranspose()
QSizeFtransposed() const
QSizeFexpandedTo(const QSizeF &o) const
QSizeFboundedTo(const QSizeF &o) const
voidscale(const QSizeF &s, Qt::AspectRatioMode mode)
QSizeFscaled(const QSizeF &s, Qt::AspectRatioMode mode) const
QSizetoSize() const
QSizeF &operator+=(const QSizeF &s)
QSizeF &operator-=(const QSizeF &s)
QSizeF &operator*=(double f)
QSizeF &operator/=(double d)
QSizeFgrownBy(const QMarginsF &m) const
QSizeFshrunkBy(const QMarginsF &m) const
voidscale(double w, double h, Qt::AspectRatioMode mode)
QSizeFscaled(double w, double h, Qt::AspectRatioMode mode) const

Detailed Description

A size is specified by a width() and a height(), both stored as double. A default-constructed size is invalid, with a width and height of -1. Use QSize for integer dimensions.

Equality comparison is fuzzy: two dimensions are considered equal if they are equal within the precision of double.

See also QSize, QPointF and QRectF.

Differences from Qt

Dimensions are always double, which is what qreal is in Nt.

Member Function Documentation

[constexpr] QSizeF::QSizeF()

Constructs an invalid size with a width and height of -1.0.

See also isValid().

[constexpr] QSizeF::QSizeF(const QSize &s)

Constructs a size with floating point accuracy from the given integer size s.

See also toSize() and QSize::toSizeF().

[constexpr] QSizeF::QSizeF(double w, double h)

Constructs a size with the given w and h.

[constexpr] QSizeF QSizeF::boundedTo(const QSizeF &o) const

Returns a size holding the minimum width and height of this size and the o size.

See also expandedTo().

[constexpr] QSizeF QSizeF::expandedTo(const QSizeF &o) const

Returns a size holding the maximum width and height of this size and the o size.

See also boundedTo().

[constexpr] QSizeF QSizeF::grownBy(const QMarginsF &m) const

Returns the size grown by the margins m.

This function was introduced in 5.14.

See also shrunkBy().

[constexpr] double QSizeF::height() const

Returns the height.

See also width(), setHeight() and rheight().

[constexpr] bool QSizeF::isEmpty() const

Returns true if the width or the height is less than or equal to 0; otherwise returns false.

See also isNull() and isValid().

bool QSizeF::isNull() const

Returns true if both the width and height are fuzzily equal to 0; otherwise returns false.

See also isEmpty() and isValid().

[constexpr] bool QSizeF::isValid() const

Returns true if both the width and the height are equal to or greater than 0; otherwise returns false.

See also isNull() and isEmpty().

[constexpr] QSizeF & QSizeF::operator*=(double f)

Multiplies both the width and height by the given factor f and returns a reference to this size.

[constexpr] QSizeF & QSizeF::operator+=(const QSizeF &s)

Adds the given s to this size and returns a reference to this size.

[constexpr] QSizeF & QSizeF::operator-=(const QSizeF &s)

Subtracts the given s from this size and returns a reference to this size.

[constexpr] QSizeF & QSizeF::operator/=(double d)

Divides both the width and height by the given divisor d and returns a reference to this size.

[constexpr] double & QSizeF::rheight()

Returns a reference to the height, allowing it to be modified directly.

See also height() and setHeight().

[constexpr] double & QSizeF::rwidth()

Returns a reference to the width, allowing it to be modified directly.

See also width() and setWidth().

void QSizeF::scale(const QSizeF &s, Qt::AspectRatioMode mode)

Scales this size to a rectangle with the given size s, according to the given mode.

See also scaled().

void QSizeF::scale(double w, double h, Qt::AspectRatioMode mode)

This is an overloaded function.

Scales the size to a rectangle of width w and height h, as mode says.

QSizeF QSizeF::scaled(const QSizeF &s, Qt::AspectRatioMode mode) const

Returns this size scaled to a rectangle with the given size s, according to the given mode.

If mode is Qt::IgnoreAspectRatio, or this size has a zero width or height, s is returned unchanged. With Qt::KeepAspectRatio the result fits inside s; with Qt::KeepAspectRatioByExpanding it covers s.

See also scale().

QSizeF QSizeF::scaled(double w, double h, Qt::AspectRatioMode mode) const

This is an overloaded function.

Returns the size scaled to a rectangle of width w and height h, as mode says.

[constexpr] void QSizeF::setHeight(double h)

Sets the height to the given h.

See also height() and setWidth().

[constexpr] void QSizeF::setWidth(double w)

Sets the width to the given w.

See also width() and setHeight().

[constexpr] QSizeF QSizeF::shrunkBy(const QMarginsF &m) const

Returns the size shrunk by the margins m.

This function was introduced in 5.14.

See also grownBy().

QSize QSizeF::toSize() const

Returns a QSize with the width and height rounded to the nearest integer.

See also QSize::toSizeF().

[constexpr] void QSizeF::transpose()

Swaps the width and height values.

See also transposed().

[constexpr] QSizeF QSizeF::transposed() const

Returns a size with the width and height values swapped.

See also transpose().

[constexpr] double QSizeF::width() const

Returns the width.

See also height(), setWidth() and rwidth().