Home · All Namespaces · All Classes · Main Classes · Grouped Classes · Modules · Functions |
The QSize class defines the size of a two-dimensional object using integer point precision. More...
#include <QSize>
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 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.
Constructs a size with an invalid width and height (i.e., isValid() returns false).
See also isValid().
Constructs a size with the given width and height.
See also setWidth() and setHeight().
Returns a size holding the minimum width and height of this size and the given otherSize.
See also expandedTo() and scale().
Returns a size holding the maximum width and height of this size and the given otherSize.
See also boundedTo() and scale().
Returns the height.
See also width() and setHeight().
Returns true if either of the width and height is less than or equal to 0; otherwise returns false.
See also isNull() and isValid().
Returns true if both the width and height is 0; otherwise returns false.
See also isValid() and isEmpty().
Returns true if both the width and height is equal to or greater than 0; otherwise returns false.
See also isNull() and isEmpty().
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;
// size becomes (100,15)
See also rwidth() and setHeight().
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;
// size becomes (120,10)
See also rheight() and setWidth().
Scales the size to a rectangle with the given width and height, according to the specified mode:
Example:
QSize t1(10, 12); t1.scale(60, 60, Qt::IgnoreAspectRatio); // t1 is (60, 60) QSize t2(10, 12); t2.scale(60, 60, Qt::KeepAspectRatio); // t2 is (50, 60) QSize t3(10, 12); t3.scale(60, 60, Qt::KeepAspectRatioByExpanding); // t3 is (60, 72)
See also setWidth() and setHeight().
This is an overloaded member function, provided for convenience.
Scales the size to a rectangle with the given size, according to the specified mode.
Sets the height to the given height.
See also rheight(), height(), and setWidth().
Sets the width to the given width.
See also rwidth(), width(), and setHeight().
Swaps the width and height values.
See also setWidth() and setHeight().
Returns the width.
See also height() and setWidth().
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().
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;
// s becomes (2,11)
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;
// s becomes (4,3)
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().
This is an overloaded member function, provided for convenience.
Returns true if s1 and s2 are different; otherwise returns false.
This is an overloaded member function, provided for convenience.
Multiplies the given size by the given factor, and returns the result rounded to the nearest integer.
See also QSize::scale().
This is an overloaded member function, provided for convenience.
Multiplies the given size by the given factor, and returns the result rounded to the nearest integer.
This is an overloaded member function, provided for convenience.
Returns the sum of s1 and s2; each component is added separately.
This is an overloaded member function, provided for convenience.
Returns s2 subtracted from s1; each component is subtracted separately.
This is an overloaded member function, provided for convenience.
Divides the given size by the given divisor, and returns the result rounded to the nearest integer.
See also QSize::scale().
This is an overloaded member function, provided for convenience.
Writes the given size to the given stream, and returns a reference to the stream.
See also Format of the QDataStream Operators.
This is an overloaded member function, provided for convenience.
Returns true if s1 and s2 are equal; otherwise returns false.
This is an overloaded member function, provided for convenience.
Reads a size from the given stream into the given size, and returns a reference to the stream.
See also Format of the QDataStream Operators.
Copyright © 2008 Nokia | Trademarks | Qt 4.4.3 |