Member Function Documentation
QSize::QSize()
Constructs a size with an invalid width and height (i.e., isValid() returns false).
See also isValid().
QSize::QSize(int width, int height)
Constructs a size with the given width and height.
See also setWidth() and setHeight().
QSize QSize::boundedTo(const QSize & otherSize) const
Returns a size holding the minimum width and height of this size and the given otherSize.
See also expandedTo() and scale().
QSize QSize::expandedTo(const QSize & otherSize) const
Returns a size holding the maximum width and height of this size and the given otherSize.
See also boundedTo() and scale().
int QSize::height() const
Returns the height.
See also width() and setHeight().
bool QSize::isEmpty() const
Returns true if either of the width and height is less than or equal to 0; otherwise returns false.
See also isNull() and isValid().
bool QSize::isNull() const
Returns true if both the width and height is 0; otherwise returns false.
See also isValid() and isEmpty().
bool QSize::isValid() const
Returns true if both the width and height is equal to or greater than 0; otherwise returns false.
See also isNull() and isEmpty().
int & QSize::rheight()
Returns a reference to the height.
Using a reference makes it possible to manipulate the height directly. For example:
QSize size(100, 10);
size.rheight() += 5;
See also rwidth() and setHeight().
int & QSize::rwidth()
Returns a reference to the width.
Using a reference makes it possible to manipulate the width directly. For example:
QSize size(100, 10);
size.rwidth() += 20;
See also rheight() and setWidth().
void QSize::scale(int width, int height, Qt::AspectRatioMode mode)
Scales the size to a rectangle with the given width and height, according to the specified mode:
- If mode is Qt::IgnoreAspectRatio, the size is set to (width, height).
- If mode is Qt::KeepAspectRatio, the current size is scaled to a rectangle as large as possible inside (width, height), preserving the aspect ratio.
- If mode is Qt::KeepAspectRatioByExpanding, the current size is scaled to a rectangle as small as possible outside (width, height), preserving the aspect ratio.
Example:
QSize t1(10, 12);
t1.scale(60, 60, Qt::IgnoreAspectRatio);
QSize t2(10, 12);
t2.scale(60, 60, Qt::KeepAspectRatio);
QSize t3(10, 12);
t3.scale(60, 60, Qt::KeepAspectRatioByExpanding);
See also setWidth(), setHeight(), and scaled().
void QSize::scale(const QSize & size, Qt::AspectRatioMode mode)
This is an overloaded function.
Scales the size to a rectangle with the given size, according to the specified mode.
QSize QSize::scaled(int width, int height, Qt::AspectRatioMode mode) const
Return a size scaled to a rectangle with the given width and height, according to the specified mode.
This function was introduced in Qt 5.0.
See also scale().
QSize QSize::scaled(const QSize & s, Qt::AspectRatioMode mode) const
This is an overloaded function.
This function was introduced in Qt 5.0.
void QSize::setHeight(int height)
Sets the height to the given height.
See also rheight(), height(), and setWidth().
void QSize::setWidth(int width)
Sets the width to the given width.
See also rwidth(), width(), and setHeight().
void QSize::transpose()
Swaps the width and height values.
See also setWidth(), setHeight(), and transposed().
QSize QSize::transposed() const
Returns a QSize with width and height swapped.
This function was introduced in Qt 5.0.
See also transpose().
int QSize::width() const
Returns the width.
See also height() and setWidth().
QSize & QSize::operator*=(qreal factor)
This is an overloaded function.
Multiplies both the width and height by the given factor, and returns a reference to the size.
Note that the result is rounded to the nearest integer.
See also scale().
QSize & QSize::operator+=(const QSize & size)
Adds the given size to this size, and returns a reference to this size. For example:
QSize s( 3, 7);
QSize r(-1, 4);
s += r;
QSize & QSize::operator-=(const QSize & size)
Subtracts the given size from this size, and returns a reference to this size. For example:
QSize s( 3, 7);
QSize r(-1, 4);
s -= r;
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
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().
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.
Reads a size from the given stream into the given size, and returns a reference to the stream.
See also Serializing Qt Data Types.