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() | |
QSize(int w, int h) | |
QSize | boundedTo(const QSize &) const |
QSize | expandedTo(const QSize &) const |
int | height() const |
bool | isEmpty() const |
bool | isNull() const |
bool | isValid() const |
int & | rheight() |
int & | rwidth() |
void | scale(int w, int h, Qt::AspectRatioMode mode) |
void | scale(const QSize &s, Qt::AspectRatioMode mode) |
QSize | scaled(int w, int h, Qt::AspectRatioMode mode) const |
QSize | scaled(const QSize &s, Qt::AspectRatioMode mode) const |
void | setHeight(int h) |
void | setWidth(int w) |
CGSize | toCGSize() const |
void | transpose() |
QSize | transposed() const |
int | width() const |
QSize & | operator*=(qreal c) |
QSize & | operator+=(const QSize &) |
QSize & | operator-=(const QSize &) |
QSize & | operator/=(qreal c) |
Related Non-Members
bool | operator!=(const QSize &s1, const QSize &s2) |
const QSize | operator*(const QSize &size, qreal factor) |
const QSize | operator*(qreal factor, const QSize &size) |
const QSize | operator+(const QSize &s1, const QSize &s2) |
const QSize | operator-(const QSize &s1, const QSize &s2) |
const QSize | operator/(const QSize &size, qreal divisor) |
QDataStream & | operator<<(QDataStream &stream, const QSize &size) |
bool | operator==(const QSize &s1, const QSize &s2) |
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()
Default constructs an instance of QSize.
QSize::QSize(int w, int h)
Default constructs an instance of QSize.
QSize QSize::boundedTo(const QSize &) const
QSize QSize::expandedTo(const QSize &) const
int QSize::height() const
See also setHeight().
bool QSize::isEmpty() const
bool QSize::isNull() const
bool QSize::isValid() const
int &QSize::rheight()
int &QSize::rwidth()
void QSize::scale(int w, int h, Qt::AspectRatioMode mode)
void QSize::scale(const QSize &s, Qt::AspectRatioMode mode)
QSize QSize::scaled(int w, int h, Qt::AspectRatioMode mode) const
QSize QSize::scaled(const QSize &s, Qt::AspectRatioMode mode) const
This is an overloaded function.
Return a size scaled to a rectangle with the given size s, according to the specified mode.
This function was introduced in Qt 5.0.
void QSize::setHeight(int h)
See also height().
void QSize::setWidth(int w)
See also width().
CGSize QSize::toCGSize() const
Creates a CGSize from a QSize.
This function was introduced in Qt 5.8.
See also QSizeF::fromCGSize().
void QSize::transpose()
Swaps the width and height values.
See also setWidth(), setHeight(), and transposed().
QSize QSize::transposed() const
int QSize::width() const
See also setWidth().
QSize &QSize::operator*=(qreal c)
QSize &QSize::operator+=(const QSize &)
QSize &QSize::operator-=(const QSize &)
QSize &QSize::operator/=(qreal c)
Related Non-Members
bool operator!=(const QSize &s1, const QSize &s2)
Returns true
if s1 and s2 are different; otherwise returns false
.
const QSize operator*(const QSize &size, qreal factor)
Multiplies the given size by the given factor, and returns the result rounded to the nearest integer.
See also QSize::scale().
const QSize operator*(qreal factor, const QSize &size)
This is an overloaded function.
Multiplies the given size by the given factor, and returns the result rounded to the nearest integer.
const QSize operator+(const QSize &s1, const QSize &s2)
Returns the sum of s1 and s2; each component is added separately.
const QSize operator-(const QSize &s1, const QSize &s2)
Returns s2 subtracted from s1; each component is subtracted separately.
const QSize operator/(const QSize &size, qreal divisor)
This is an overloaded function.
Divides the given size by the given divisor, and returns the result rounded to the nearest integer.
See also QSize::scale().
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.
bool operator==(const QSize &s1, const QSize &s2)
Returns true
if s1 and s2 are equal; otherwise returns false
.
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.