QSizeF Class
The QSizeF class defines the size of a two-dimensional object using floating point precision. More...
Header: | #include <QSizeF> |
qmake: | QT += core |
Public Functions
QSizeF() | |
QSizeF(const QSize &sz) | |
QSizeF(qreal w, qreal h) | |
QSizeF | boundedTo(const QSizeF &) const |
QSizeF | expandedTo(const QSizeF &) const |
qreal | height() const |
bool | isEmpty() const |
bool | isNull() const |
bool | isValid() const |
qreal & | rheight() |
qreal & | rwidth() |
void | scale(qreal w, qreal h, Qt::AspectRatioMode mode) |
void | scale(const QSizeF &s, Qt::AspectRatioMode mode) |
QSizeF | scaled(qreal w, qreal h, Qt::AspectRatioMode mode) const |
QSizeF | scaled(const QSizeF &s, Qt::AspectRatioMode mode) const |
void | setHeight(qreal h) |
void | setWidth(qreal w) |
CGSize | toCGSize() const |
QSize | toSize() const |
void | transpose() |
QSizeF | transposed() const |
qreal | width() const |
QSizeF & | operator*=(qreal c) |
QSizeF & | operator+=(const QSizeF &) |
QSizeF & | operator-=(const QSizeF &) |
QSizeF & | operator/=(qreal c) |
Static Public Members
QSizeF | fromCGSize(CGSize size) |
Related Non-Members
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) |
Detailed Description
The QSizeF class defines the size of a two-dimensional object using floating 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.
The QSizeF class also provides the toSize() function returning a QSize 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 also QSize, QPointF, and QRectF.
Member Function Documentation
QSizeF::QSizeF()
Default constructs an instance of QSizeF.
QSizeF::QSizeF(const QSize &sz)
Default constructs an instance of QSizeF.
QSizeF::QSizeF(qreal w, qreal h)
Default constructs an instance of QSizeF.
QSizeF QSizeF::boundedTo(const QSizeF &) const
QSizeF QSizeF::expandedTo(const QSizeF &) const
[static]
QSizeF QSizeF::fromCGSize(CGSize size)
Creates a QRectF from size.
This function was introduced in Qt 5.8.
See also toCGSize().
qreal QSizeF::height() const
See also setHeight().
bool QSizeF::isEmpty() const
bool QSizeF::isNull() const
bool QSizeF::isValid() const
qreal &QSizeF::rheight()
qreal &QSizeF::rwidth()
void QSizeF::scale(qreal w, qreal h, Qt::AspectRatioMode mode)
void QSizeF::scale(const QSizeF &s, Qt::AspectRatioMode mode)
QSizeF QSizeF::scaled(qreal w, qreal h, Qt::AspectRatioMode mode) const
QSizeF QSizeF::scaled(const QSizeF &s, Qt::AspectRatioMode mode) const
This is an overloaded function.
Returns 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 QSizeF::setHeight(qreal h)
See also height().
void QSizeF::setWidth(qreal w)
See also width().
CGSize QSizeF::toCGSize() const
Creates a CGSize from a QSizeF.
This function was introduced in Qt 5.8.
See also fromCGSize().
QSize QSizeF::toSize() const
void QSizeF::transpose()
Swaps the width and height values.
See also setWidth(), setHeight(), and transposed().
QSizeF QSizeF::transposed() const
qreal QSizeF::width() const
See also setWidth().
QSizeF &QSizeF::operator*=(qreal c)
QSizeF &QSizeF::operator+=(const QSizeF &)
QSizeF &QSizeF::operator-=(const QSizeF &)
QSizeF &QSizeF::operator/=(qreal c)
Related Non-Members
bool operator!=(const QSizeF &s1, const QSizeF &s2)
Returns true
if s1 and s2 are different; otherwise returns false
.
const QSizeF operator*(const QSizeF &size, qreal factor)
This is an overloaded function.
Multiplies the given size by the given factor and returns the result.
See also QSizeF::scale().
const QSizeF operator*(qreal factor, const QSizeF &size)
This is an overloaded function.
Multiplies the given size by the given factor and returns the result.
const QSizeF operator+(const QSizeF &s1, const QSizeF &s2)
Returns the sum of s1 and s2; each component is added separately.
const QSizeF operator-(const QSizeF &s1, const QSizeF &s2)
Returns s2 subtracted from s1; each component is subtracted separately.
const QSizeF operator/(const QSizeF &size, qreal divisor)
This is an overloaded function.
Divides the given size by the given divisor and returns the result.
See also QSizeF::scale().
QDataStream &operator<<(QDataStream &stream, const QSizeF &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 QSizeF &s1, const QSizeF &s2)
Returns true
if s1 and s2 are equal; otherwise returns false.
QDataStream &operator>>(QDataStream &stream, QSizeF &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.