QSize Class

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

Header: #include <QSize>
qmake: QT += core

Public Functions

QSize &operator/=(qreal divisor)
QDataStream &operator<<(QDataStream &stream, const QSize &size)
QDataStream &operator>>(QDataStream &stream, QSize &size)

Detailed Description

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

A size is specified by a width() and a height(). It can be set in the constructor and changed using the setWidth(), setHeight(), or scale() functions, or using arithmetic operators. A size can also be manipulated directly by retrieving references to the width and height using the rwidth() and rheight() functions. Finally, the width and height can be swapped using the transpose() function.

The isValid() function determines if a size is valid (a valid size has both width and height greater than or equal to zero). The isEmpty() function returns true if either of the width and height is less than, or equal to, zero, while the isNull() function returns true only if both the width and the height is zero.

Use the expandedTo() function to retrieve a size which holds the maximum height and width of this size and a given size. Similarly, the boundedTo() function returns a size which holds the minimum height and width of this size and a given size.

QSize objects can be streamed as well as compared.

See also QSizeF, QPoint, and QRect.

Member Function Documentation

QSize &QSize::operator/=(qreal divisor)

This is an overloaded function.

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

Note that the result is rounded to the nearest integer.

See also QSize::scale().

Related Non-Members

QDataStream &operator<<(QDataStream &stream, const QSize &size)

Writes the given size to the given stream, and returns a reference to the stream.

See also Serializing Qt Data Types.

QDataStream &operator>>(QDataStream &stream, QSize &size)

Reads a size from the given stream into the given size, and returns a reference to the stream.

See also Serializing Qt Data Types.