
We bake cookies in your browser for a better experience. Using this site means that you consent.Read More
TheQSizeF class defines the size of a two-dimensional object using floating point precision.More...
| Header: | #include <QSizeF> |
| QSizeF() | |
| QSizeF(const QSize & size) | |
| QSizeF(qreal width, qreal height) | |
| QSizeF | boundedTo(const QSizeF & otherSize) const |
| QSizeF | expandedTo(const QSizeF & otherSize) const |
| qreal | height() const |
| bool | isEmpty() const |
| bool | isNull() const |
| bool | isValid() const |
| qreal & | rheight() |
| qreal & | rwidth() |
| void | scale(qreal width, qreal height, Qt::AspectRatioMode mode) |
| void | scale(const QSizeF & size, Qt::AspectRatioMode mode) |
| void | setHeight(qreal height) |
| void | setWidth(qreal width) |
| QSize | toSize() const |
| void | transpose() |
| qreal | width() const |
| QSizeF & | operator*=(qreal factor) |
| QSizeF & | operator+=(const QSizeF & size) |
| QSizeF & | operator-=(const QSizeF & size) |
| QSizeF & | operator/=(qreal divisor) |
| bool | operator!=(const QSizeF & s1, const QSizeF & s2) |
| const QSizeF | operator*(const QSizeF & size, qreal factor) |
| const QSizeF | operator*(qreal factor, const QSizeF & size) |
| const QSizeF | operator+(const QSizeF & s1, const QSizeF & s2) |
| const QSizeF | operator-(const QSizeF & s1, const QSizeF & s2) |
| const QSizeF | operator/(const QSizeF & size, qreal divisor) |
| QDataStream & | operator<<(QDataStream & stream, const QSizeF & size) |
| bool | operator==(const QSizeF & s1, const QSizeF & s2) |
| QDataStream & | operator>>(QDataStream & stream, QSizeF & size) |
TheQSizeF class defines the size of a two-dimensional object using floating point precision.
A size is specified by awidth() and aheight(). It can be set in the constructor and changed using thesetWidth(),setHeight(), orscale() functions, or using arithmetic operators. A size can also be manipulated directly by retrieving references to the width and height using therwidth() andrheight() functions. Finally, the width and height can be swapped using thetranspose() function.
TheisValid() function determines if a size is valid. A valid size has both width and height greater than or equal to zero. TheisEmpty() function returns true if either of the width and height isless than (or equal to) zero, while theisNull() function returns true only if both the width and the height is zero.
Use theexpandedTo() function to retrieve a size which holds the maximum height and width of this size and a given size. Similarly, theboundedTo() function returns a size which holds the minimum height and width of this size and a given size.
TheQSizeF class also provides thetoSize() function returning aQSize copy of this size, constructed by rounding the width and height to the nearest integers.
QSizeF objects can be streamed as well as compared.
See alsoQSize,QPointF, andQRectF.
Constructs an invalid size.
See alsoisValid().
Constructs a size with floating point accuracy from the givensize.
See alsotoSize().
Constructs a size with the givenwidth andheight.
Returns a size holding the minimum width and height of this size and the givenotherSize.
See alsoexpandedTo() andscale().
Returns a size holding the maximum width and height of this size and the givenotherSize.
See alsoboundedTo() andscale().
Returns the height.
See alsowidth() andsetHeight().
Returns true if either of the width and height is less than or equal to 0; otherwise returns false.
See alsoisNull() andisValid().
Returns true if both the width and height are +0.0; otherwise returns false.
Note:Since this function treats +0.0 and -0.0 differently, sizes with zero width and height where either or both values have a negative sign are not defined to be null sizes.
See alsoisValid() andisEmpty().
Returns true if both the width and height is equal to or greater than 0; otherwise returns false.
See alsoisNull() andisEmpty().
Returns a reference to the height.
Using a reference makes it possible to manipulate the height directly. For example:
QSizeF size(100,10.2);size.rheight()+=5.5;// size becomes (100,15.7)
See alsorwidth() andsetHeight().
Returns a reference to the width.
Using a reference makes it possible to manipulate the width directly. For example:
QSizeF size(100.3,10);size.rwidth()+=20.5;// size becomes (120.8,10)
See alsorheight() andsetWidth().
Scales the size to a rectangle with the givenwidth andheight, according to the specifiedmode.
Example:
QSizeF t1(10,12);t1.scale(60,60,Qt::IgnoreAspectRatio);// t1 is (60, 60)QSizeF t2(10,12);t2.scale(60,60,Qt::KeepAspectRatio);// t2 is (50, 60)QSizeF t3(10,12);t3.scale(60,60,Qt::KeepAspectRatioByExpanding);// t3 is (60, 72)
See alsosetWidth() andsetHeight().
This is an overloaded function.
Scales the size to a rectangle with the givensize, according to the specifiedmode.
Sets the height to the givenheight.
See alsoheight(),rheight(), andsetWidth().
Sets the width to the givenwidth.
See alsowidth(),rwidth(), andsetHeight().
Returns an integer based copy of this size.
Note that the coordinates in the returned size will be rounded to the nearest integer.
See alsoQSizeF().
Swaps the width and height values.
See alsosetWidth() andsetHeight().
Returns the width.
See alsoheight() andsetWidth().
This is an overloaded function.
Multiplies both the width and height by the givenfactor and returns a reference to the size.
See alsoscale().
Adds the givensize to this size and returns a reference to this size. For example:
Subtracts the givensize from this size and returns a reference to this size. For example:
This is an overloaded function.
Divides both the width and height by the givendivisor and returns a reference to the size.
See alsoscale().
Returns true ifs1 ands2 are different; otherwise returns false.
This is an overloaded function.
Multiplies the givensize by the givenfactor and returns the result.
See alsoQSizeF::scale().
This is an overloaded function.
Multiplies the givensize by the givenfactor and returns the result.
Returns the sum ofs1 ands2; each component is added separately.
Returnss2 subtracted froms1; each component is subtracted separately.
This is an overloaded function.
Divides the givensize by the givendivisor and returns the result.
See alsoQSizeF::scale().
Writes the givensize to the givenstream and returns a reference to the stream.
See alsoSerializing Qt Data Types.
Returns true ifs1 ands2 are equal; otherwise returns false.
Reads a size from the givenstream into the givensize and returns a reference to the stream.
See alsoSerializing Qt Data Types.
© 2016 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of theGNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.