QSizeF Class
The QSizeF class defines the size of a two-dimensional object using floating point precision. More…
| Header | #include <QSizeF> |
|---|---|
| CMake | target_link_libraries(app PRIVATE Nt::Core) |
| Module | Nt Core C++ Classes |
List of all members, including inherited members
Public Functions
| QSizeF() | |
| QSizeF(const QSize &s) | |
| QSizeF(double w, double h) | |
| bool | isNull() const |
| bool | isEmpty() const |
| bool | isValid() const |
| double | width() const |
| double | height() const |
| void | setWidth(double w) |
| void | setHeight(double h) |
| double & | rwidth() |
| double & | rheight() |
| void | transpose() |
| QSizeF | transposed() const |
| QSizeF | expandedTo(const QSizeF &o) const |
| QSizeF | boundedTo(const QSizeF &o) const |
| void | scale(const QSizeF &s, Qt::AspectRatioMode mode) |
| QSizeF | scaled(const QSizeF &s, Qt::AspectRatioMode mode) const |
| QSize | toSize() const |
| QSizeF & | operator+=(const QSizeF &s) |
| QSizeF & | operator-=(const QSizeF &s) |
| QSizeF & | operator*=(double f) |
| QSizeF & | operator/=(double d) |
| QSizeF | grownBy(const QMarginsF &m) const |
| QSizeF | shrunkBy(const QMarginsF &m) const |
| void | scale(double w, double h, Qt::AspectRatioMode mode) |
| QSizeF | scaled(double w, double h, Qt::AspectRatioMode mode) const |
Detailed Description
A size is specified by a width() and a height(), both stored as double. A default-constructed size is invalid, with a width and height of -1. Use QSize for integer dimensions.
Equality comparison is fuzzy: two dimensions are considered equal if they are equal within the precision of double.
See also QSize, QPointF and QRectF.
Differences from Qt
Dimensions are always double, which is what qreal is in Nt.
Member Function Documentation
QSizeF::QSizeF()
Constructs an invalid size with a width and height of -1.0.
See also isValid().
QSizeF::QSizeF(const QSize &s)
Constructs a size with floating point accuracy from the given integer size s.
See also toSize() and QSize::toSizeF().
QSizeF::QSizeF(double w, double h)
Constructs a size with the given w and h.
QSizeF QSizeF::boundedTo(const QSizeF &o) const
Returns a size holding the minimum width and height of this size and the o size.
See also expandedTo().
QSizeF QSizeF::expandedTo(const QSizeF &o) const
Returns a size holding the maximum width and height of this size and the o size.
See also boundedTo().
QSizeF QSizeF::grownBy(const QMarginsF &m) const
Returns the size grown by the margins m.
This function was introduced in 5.14.
See also shrunkBy().
double QSizeF::height() const
Returns the height.
See also width(), setHeight() and rheight().
bool QSizeF::isEmpty() const
Returns true if the width or the height is less than or equal to 0; otherwise returns false.
See also isNull() and isValid().
bool QSizeF::isNull() const
Returns true if both the width and height are fuzzily equal to 0; otherwise returns false.
See also isEmpty() and isValid().
bool QSizeF::isValid() const
Returns true if both the width and the height are equal to or greater than 0; otherwise returns false.
See also isNull() and isEmpty().
QSizeF & QSizeF::operator*=(double f)
Multiplies both the width and height by the given factor f and returns a reference to this size.
QSizeF & QSizeF::operator+=(const QSizeF &s)
Adds the given s to this size and returns a reference to this size.
QSizeF & QSizeF::operator-=(const QSizeF &s)
Subtracts the given s from this size and returns a reference to this size.
QSizeF & QSizeF::operator/=(double d)
Divides both the width and height by the given divisor d and returns a reference to this size.
double & QSizeF::rheight()
Returns a reference to the height, allowing it to be modified directly.
See also height() and setHeight().
double & QSizeF::rwidth()
Returns a reference to the width, allowing it to be modified directly.
See also width() and setWidth().
void QSizeF::scale(const QSizeF &s, Qt::AspectRatioMode mode)
Scales this size to a rectangle with the given size s, according to the given mode.
See also scaled().
void QSizeF::scale(double w, double h, Qt::AspectRatioMode mode)
This is an overloaded function.
Scales the size to a rectangle of width w and height h, as mode says.
QSizeF QSizeF::scaled(const QSizeF &s, Qt::AspectRatioMode mode) const
Returns this size scaled to a rectangle with the given size s, according to the given mode.
If mode is Qt::IgnoreAspectRatio, or this size has a zero width or height, s is returned unchanged. With Qt::KeepAspectRatio the result fits inside s; with Qt::KeepAspectRatioByExpanding it covers s.
See also scale().
QSizeF QSizeF::scaled(double w, double h, Qt::AspectRatioMode mode) const
This is an overloaded function.
Returns the size scaled to a rectangle of width w and height h, as mode says.
void QSizeF::setHeight(double h)
Sets the height to the given h.
See also height() and setWidth().
void QSizeF::setWidth(double w)
Sets the width to the given w.
See also width() and setHeight().
QSizeF QSizeF::shrunkBy(const QMarginsF &m) const
Returns the size shrunk by the margins m.
This function was introduced in 5.14.
See also grownBy().
QSize QSizeF::toSize() const
Returns a QSize with the width and height rounded to the nearest integer.
See also QSize::toSizeF().
void QSizeF::transpose()
Swaps the width and height values.
See also transposed().
QSizeF QSizeF::transposed() const
Returns a size with the width and height values swapped.
See also transpose().
double QSizeF::width() const
Returns the width.
See also height(), setWidth() and rwidth().