6.0.0-rc4Source

QSize Class

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

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

List of all members, including inherited members

Public Functions

QSize()
QSize(int w, int h)
boolisNull() const
boolisEmpty() const
boolisValid() const
intwidth() const
intheight() const
voidsetWidth(int w)
voidsetHeight(int h)
int &rwidth()
int &rheight()
voidtranspose()
QSizetransposed() const
QSizeexpandedTo(const QSize &o) const
QSizeboundedTo(const QSize &o) const
voidscale(int w, int h, Qt::AspectRatioMode mode)
voidscale(const QSize &s, Qt::AspectRatioMode mode)
QSizescaled(int w, int h, Qt::AspectRatioMode mode) const
QSizescaled(const QSize &s, Qt::AspectRatioMode mode) const
QSizeFtoSizeF() const
QSize &operator+=(const QSize &s)
QSize &operator-=(const QSize &s)
QSize &operator*=(double f)
QSize &operator/=(double d)
QSizegrownBy(QMargins m) const
QSizeshrunkBy(QMargins m) const

Detailed Description

A size is specified by a width() and a height(), both stored as int. A default-constructed size is invalid, with a width and height of -1. Use QSizeF for floating-point dimensions.

See also QSizeF, QPoint and QRect.

Differences from Qt

None.

Member Function Documentation

[constexpr] QSize::QSize()

Constructs a size with an invalid width and height, both -1.

See also isValid().

[constexpr] QSize::QSize(int w, int h)

Constructs a size with the given w and h.

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

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

See also expandedTo().

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

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

See also boundedTo().

[constexpr] QSize QSize::grownBy(QMargins m) const

Returns the size grown by the margins m: wider by the left and right margins and taller by the top and bottom ones.

This function was introduced in 5.14.

See also shrunkBy().

[constexpr] int QSize::height() const

Returns the height.

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

[constexpr] bool QSize::isEmpty() const

Returns true if the width or the height is less than 1; otherwise returns false.

See also isNull() and isValid().

[constexpr] bool QSize::isNull() const

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

See also isEmpty() and isValid().

[constexpr] bool QSize::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().

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

Multiplies both the width and height by the given factor f, rounds each to the nearest integer, and returns a reference to this size.

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

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

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

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

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

Divides both the width and height by the given divisor d, rounds each to the nearest integer, and returns a reference to this size.

[constexpr] int & QSize::rheight()

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

See also height() and setHeight().

[constexpr] int & QSize::rwidth()

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

See also width() and setWidth().

void QSize::scale(int w, int h, Qt::AspectRatioMode mode)

This is an overloaded function.

Scales this size to a rectangle with the given w and h, according to the given mode.

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

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

See also scaled().

QSize QSize::scaled(int w, int h, Qt::AspectRatioMode mode) const

This is an overloaded function.

Returns this size scaled to a rectangle with the given w and h, according to the given mode.

QSize QSize::scaled(const QSize &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().

[constexpr] void QSize::setHeight(int h)

Sets the height to the given h.

See also height() and setWidth().

[constexpr] void QSize::setWidth(int w)

Sets the width to the given w.

See also width() and setHeight().

[constexpr] QSize QSize::shrunkBy(QMargins m) const

Returns the size shrunk by the margins m.

This function was introduced in 5.14.

See also grownBy().

[constexpr] QSizeF QSize::toSizeF() const

Returns this size as a QSizeF.

See also QSizeF::toSize().

[constexpr] void QSize::transpose()

Swaps the width and height values.

See also transposed().

[constexpr] QSize QSize::transposed() const

Returns a size with the width and height values swapped.

See also transpose().

[constexpr] int QSize::width() const

Returns the width.

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