![]() |
Qt 6.x
The Qt SDK
|
\inmodule QtCore More...
#include <qsize.h>
Public Member Functions | |
constexpr | QSizeF () noexcept |
Constructs an invalid size. | |
constexpr | QSizeF (const QSize &sz) noexcept |
Constructs a size with floating point accuracy from the given size. | |
constexpr | QSizeF (qreal w, qreal h) noexcept |
Constructs a size with the given finite width and height. | |
bool | isNull () const noexcept |
Returns true if both the width and height are 0.0 (ignoring the sign); otherwise returns false . | |
constexpr bool | isEmpty () const noexcept |
Returns true if either of the width and height is less than or equal to 0; otherwise returns false . | |
constexpr bool | isValid () const noexcept |
Returns true if both the width and height are equal to or greater than 0; otherwise returns false . | |
constexpr qreal | width () const noexcept |
Returns the width. | |
constexpr qreal | height () const noexcept |
Returns the height. | |
constexpr void | setWidth (qreal w) noexcept |
Sets the width to the given finite width. | |
constexpr void | setHeight (qreal h) noexcept |
Sets the height to the given finite height. | |
void | transpose () noexcept |
Swaps the width and height values. | |
constexpr QSizeF | transposed () const noexcept |
void | scale (qreal w, qreal h, Qt::AspectRatioMode mode) noexcept |
Scales the size to a rectangle with the given width and height, according to the specified mode. | |
void | scale (const QSizeF &s, Qt::AspectRatioMode mode) noexcept |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Scales the size to a rectangle with the given size, according to the specified mode. | |
QSizeF | scaled (qreal w, qreal h, Qt::AspectRatioMode mode) const noexcept |
QSizeF | scaled (const QSizeF &s, Qt::AspectRatioMode mode) const noexcept |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. | |
constexpr QSizeF | expandedTo (const QSizeF &) const noexcept |
Returns a size holding the maximum width and height of this size and the given otherSize. | |
constexpr QSizeF | boundedTo (const QSizeF &) const noexcept |
Returns a size holding the minimum width and height of this size and the given otherSize. | |
constexpr QSizeF | grownBy (QMarginsF m) const noexcept |
constexpr QSizeF | shrunkBy (QMarginsF m) const noexcept |
constexpr qreal & | rwidth () noexcept |
Returns a reference to the width. | |
constexpr qreal & | rheight () noexcept |
Returns a reference to the height. | |
constexpr QSizeF & | operator+= (const QSizeF &) noexcept |
Adds the given size to this size and returns a reference to this size. | |
constexpr QSizeF & | operator-= (const QSizeF &) noexcept |
Subtracts the given size from this size and returns a reference to this size. | |
constexpr QSizeF & | operator*= (qreal c) noexcept |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Multiplies both the width and height by the given finite factor and returns a reference to the size. | |
QSizeF & | operator/= (qreal c) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Divides both the width and height by the given divisor and returns a reference to the size. | |
constexpr QSize | toSize () const noexcept |
Returns an integer based copy of this size. | |
Friends | |
QT_WARNING_PUSH QT_WARNING_DISABLE_FLOAT_COMPARE friend constexpr bool | operator== (const QSizeF &s1, const QSizeF &s2) |
Returns true if s1 and s2 are approximately equal; otherwise returns false. | |
QT_WARNING_POP friend constexpr bool | operator!= (const QSizeF &s1, const QSizeF &s2) |
Returns true if s1 and s2 are sufficiently different; otherwise returns false . | |
constexpr QSizeF | operator+ (const QSizeF &s1, const QSizeF &s2) noexcept |
Returns the sum of s1 and s2; each component is added separately. | |
constexpr QSizeF | operator- (const QSizeF &s1, const QSizeF &s2) noexcept |
Returns s2 subtracted from s1; each component is subtracted separately. | |
constexpr QSizeF | operator* (const QSizeF &s, qreal c) noexcept |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Multiplies the given size by the given finite factor and returns the result. | |
constexpr QSizeF | operator* (qreal c, const QSizeF &s) noexcept |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Multiplies the given size by the given finite factor and returns the result. | |
QSizeF | operator/ (const QSizeF &s, qreal c) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Divides the given size by the given divisor and returns the result. | |
template<std::size_t I, typename S , std::enable_if_t<(I< 2), bool > = true, std::enable_if_t< std::is_same_v< q20::remove_cvref_t< S >, QSizeF >, bool > = true> | |
constexpr decltype(auto) | get (S &&s) noexcept |
Related Symbols | |
(Note that these are not member symbols.) | |
QDataStream & | operator<< (QDataStream &stream, const QSizeF &size) |
Writes the given size to the given stream and returns a reference to the stream. | |
QDataStream & | operator>> (QDataStream &stream, QSizeF &size) |
Reads a size from the given stream into the given size and returns a reference to the stream. | |
\inmodule QtCore
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.
|
inlineconstexprnoexcept |
Constructs an invalid size.
Definition at line 306 of file qsize.h.
Referenced by transposed().
|
inlineconstexprnoexcept |
Constructs a size with floating point accuracy from the given size.
Returns a size holding the minimum width and height of this size and the given otherSize.
Definition at line 385 of file qsize.h.
References qMin().
Referenced by QQuickStackLayout::rearrange(), and QGraphicsView::sizeHint().
Returns a size holding the maximum width and height of this size and the given otherSize.
Definition at line 380 of file qsize.h.
References qMax().
Referenced by QQuickStackLayout::rearrange(), and QQuickStackLayout::sizeHint().
|
inlineconstexprnoexcept |
Returns the height.
Definition at line 324 of file qsize.h.
Referenced by QEglFSKmsScreen::QEglFSKmsScreen(), QQuickSelectionRectanglePrivate::QQuickSelectionRectanglePrivate(), _q_boundGeometryToSizeConstraints(), alignedRect(), QQuickLayoutPrivate::applySizeHints(), QGridLayoutItem::box(), QQuickBorderImagePrivate::calculateRects(), QQuickTableViewPrivate::calculateTopLeft(), QQuickTableViewPrivate::canLoadTableEdge(), centerOffset(), QBlitterPaintEnginePrivate::clipAndDrawPixmap(), closestAcceptableSize(), combineImplicitHints(), combineSize(), QQuickPaintedItem::contentsBoundingRect(), QQuickStyleItem::contentSize(), QQuickPopup::contentSizeChange(), QQuickScrollView::contentSizeChange(), QGraphicsTextItemPrivate::controlOffset(), QScrollerPrivate::createScrollingSegments(), QQuickRow::doPositioning(), QQuickFlow::doPositioning(), QSplashScreen::drawContents(), QMacStyle::drawControl(), QItemDelegate::drawDisplay(), QTextDocumentLayoutPrivate::drawFrame(), QTextDocumentLayoutPrivate::drawTableCell(), QQuickLayout::dumpLayoutTreeRecursive(), QTextDocumentLayout::dynamicPageCount(), QGridLayoutItem::effectiveMaxSize(), QGraphicsLayoutItemPrivate::effectiveSizeHints(), QQuickLayout::effectiveSizeHints_helper(), QScroller::ensureVisible(), getSize(), QQuickNinePatchNode::initialize(), QStyle::itemPixmapRect(), QQuickIconLabelPrivate::layout(), QTextDocumentLayoutPrivate::layoutCell(), QTextDocumentLayoutPrivate::layoutFlow(), QTextDocumentLayoutPrivate::layoutFrame(), QQuickTableViewPrivate::layoutHorizontalEdge(), QLabelPrivate::layoutRect(), QTextDocumentLayoutPrivate::layoutTable(), marginsOffset(), QGraphicsLayoutItem::maximumHeight(), QQuickPdfDocument::maxPageHeight(), QPaintDeviceWindow::metric(), QWidget::metric(), QOpenGLWidget::metric(), QGraphicsLayoutItem::minimumHeight(), operator<<(), operator<<(), operator<<(), QSGSoftwareSpriteNode::paint(), QPagePreview::paintEvent(), QScreen::physicalDotsPerInch(), QScreen::physicalDotsPerInchY(), QQC2::QWindowsXPStylePrivate::pixelMetricFromSystemDp(), QWindowsVistaStylePrivate::pixelMetricFromSystemDp(), QtWayland::TouchExtensionGlobal::postTouchEvent(), QGraphicsLayoutItem::preferredHeight(), QQuickBasePositioner::prePositioning(), QTextDocument::print(), QWindowsPrintDevice::printableMargins(), QSGOpenVGHelpers::qDrawBorderImage(), qt_convertUnits(), QSvgIOHandler::read(), QPdfIOHandler::read(), QSGSoftwareSpriteNode::rect(), QtGraphicsAnchorLayout::AnchorData::refreshSizeHints(), QQuickTableViewPrivate::relayoutTableItems(), QSGOpenVGSpriteNode::render(), QPdfDocument::render(), QTextDocumentLayout::resizeInlineObject(), QQuickTableViewPrivate::scrollTowardsSelectionPoint(), QQuickStyleItem::setContentHeight(), QScrollerPrivate::setContentPositionHelperDragging(), QPageLayoutPrivate::setDefaultMargins(), QWasmWindow::setGeometry(), QGraphicsAnchorLayoutPrivate::setItemsGeometries(), QQuickLayoutAttached::setMaximumImplicitSize(), QQuickLayoutAttached::setMinimumImplicitSize(), QPageLayout::setOrientation(), QWin32PrintEnginePrivate::setPageSize(), QQuickTextPrivate::signalSizeChange(), QLabelPrivate::sizeForWidth(), QGridLayoutEngine::sizeHint(), QQuickLayoutAttached::sizeHint(), QWindowsTheme::standardPixmap(), QQC2_NAMESPACE::QMacStyle::subControlRect(), QMacStyle::subControlRect(), QGraphicsTextItemPrivate::textControl(), QItemDelegate::textRectangle(), to_d2d_size_u(), QQuickTableViewPrivate::updateAverageRowHeight(), QQuickTextInputPrivate::updateBaselineOffset(), QQuickMultiEffectPrivate::updateBlurItemSizes(), QQuickTableViewPrivate::updateContentHeight(), QQuickTableViewPrivate::updateExtents(), QWin32PrintEnginePrivate::updateMetrics(), QQuickStyleItem::updatePaintNode(), QQuickNinePatchImagePrivate::updatePatches(), QWasmScreen::updateQScreenAndCanvasRenderSize(), QQuickTextPrivate::updateSize(), and QQuickTextInputPrivate::updateVerticalScroll().
|
inlineconstexprnoexcept |
Returns true
if either of the width and height is less than or equal to 0; otherwise returns false
.
Definition at line 315 of file qsize.h.
Referenced by QXcbScreen::QXcbScreen(), QKmsDevice::createScreenForConnector(), QQC2::QWindowsXPStyle::drawComplexControl(), QWindowsVistaStyle::drawComplexControl(), QDeclarativeGeoMap::geometryChange(), operator<<(), QEglFSKmsScreen::physicalSize(), QXcbScreen::setMonitor(), QXcbScreen::updateGeometry(), and QGraphicsVideoItemPrivate::updateRects().
|
inlinenoexcept |
Returns true
if both the width and height are 0.0 (ignoring the sign); otherwise returns false
.
Definition at line 312 of file qsize.h.
References qIsNull().
Referenced by QQuickStackLayout::rearrange(), and QTextEdit::resizeEvent().
|
inlineconstexprnoexcept |
Returns true
if both the width and height are equal to or greater than 0; otherwise returns false
.
Definition at line 318 of file qsize.h.
Referenced by QGraphicsWidget::adjustSize(), QGraphicsLayoutItem::effectiveSizeHint(), QQuickLayout::effectiveSizeHints_helper(), QQuickStackLayout::rearrange(), QQuickStackLayout::sizeHint(), and QQuickNinePatchImage::updatePaintNode().
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Multiplies both the width and height by the given finite factor and returns a reference to the size.
Adds the given size to this size and returns a reference to this size.
For example:
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Divides both the width and height by the given divisor and returns a reference to the size.
The divisor must not be either zero or NaN.
Definition at line 372 of file qsize.h.
References Q_ASSERT, qFuzzyIsNull(), and qIsFinite().
|
inlineconstexprnoexcept |
Returns a reference to the height.
Using a reference makes it possible to manipulate the height directly. For example:
Definition at line 348 of file qsize.h.
Referenced by QGraphicsLayoutItemPrivate::effectiveSizeHints(), QQuickLayout::effectiveSizeHints_helper(), QTextDocument::print(), QGraphicsLayoutItemPrivate::setSizeComponent(), and QQuickTableViewPrivate::updateExtents().
|
inlineconstexprnoexcept |
Returns a reference to the width.
Using a reference makes it possible to manipulate the width directly. For example:
Definition at line 345 of file qsize.h.
Referenced by QGraphicsLayoutItemPrivate::effectiveSizeHints(), QQuickLayout::effectiveSizeHints_helper(), QTextDocument::print(), and QQuickTableViewPrivate::updateExtents().
|
inlinenoexcept |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Scales the size to a rectangle with the given size, according to the specified mode.
Definition at line 339 of file qsize.h.
References scaled().
|
inlinenoexcept |
Scales the size to a rectangle with the given width and height, according to the specified mode.
\list
Example:
Definition at line 336 of file qsize.h.
Referenced by QGraphicsVideoItemPrivate::updateRects().
|
noexcept |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Returns a size scaled to a rectangle with the given size s, according to the specified mode.
Definition at line 640 of file qsize.cpp.
References Qt::IgnoreAspectRatio, Qt::KeepAspectRatio, and qIsNull().
|
inlinenoexcept |
Sets the height to the given finite height.
Definition at line 330 of file qsize.h.
Referenced by QKmsDevice::createScreenForConnector(), QQuickColumn::doPositioning(), QQuickRow::doPositioning(), QQuickGrid::doPositioning(), QQuickFlow::doPositioning(), QQuickLayout::effectiveSizeHints_helper(), QQuickIconLabelPrivate::layout(), operator>>(), QQuickDayOfWeekRowPrivate::resizeItems(), QQuickMonthGridPrivate::resizeItems(), QQuickWeekNumberColumnPrivate::resizeItems(), QQuickStyleItem::setContentHeight(), QTextDocument::setTextWidth(), and QQuickTableViewPrivate::updateAverageRowHeight().
Sets the width to the given finite width.
Definition at line 327 of file qsize.h.
Referenced by QKmsDevice::createScreenForConnector(), QQuickColumn::doPositioning(), QQuickRow::doPositioning(), QQuickGrid::doPositioning(), QQuickFlow::doPositioning(), QQuickLayout::effectiveSizeHints_helper(), getSize(), QQuickIconLabelPrivate::layout(), operator>>(), QQuickDayOfWeekRowPrivate::resizeItems(), QQuickMonthGridPrivate::resizeItems(), QQuickWeekNumberColumnPrivate::resizeItems(), QQuickStyleItem::setContentWidth(), QTextDocument::setTextWidth(), and QQuickTableViewPrivate::updateAverageColumnWidth().
|
inlineconstexprnoexcept |
Returns an integer based copy of this size.
Note that the coordinates in the returned size will be rounded to the nearest integer.
Definition at line 390 of file qsize.h.
References qRound().
Referenced by QWhatsThat::QWhatsThat(), QCommonStylePrivate::calculateElidedText(), QQC2::QCommonStylePrivate::calculateElidedText(), QPdfIOHandler::currentImageRect(), QQuickCanvasItem::geometryChange(), QDeclarativeGeoMap::geometryChange(), QQuickStyleItem::imageSize(), QQuickContext2D::init(), QQuickCanvasItem::loadImage(), QWatermarkLabel::minimumSizeHint(), QVideoFrame::paint(), QPagePreview::paintEvent(), QSGOpenVGHelpers::qDrawBorderImage(), qt_blurImage(), qt_convertUnitsToPoints(), QDeclarativeGeoMapCopyrightNotice::rasterizeHtmlAndUpdate(), QPdfIOHandler::read(), QQuickDesignerSupport::refFromEffectItem(), QTextEditPrivate::relayoutDocument(), QVideoWindowPrivate::render(), QSplashScreen::setPixmap(), QSvgTinyDocument::size(), QWaylandWlShellSurface::sizeForResize(), QGraphicsView::sizeHint(), QWindowsVistaStyle::standardIcon(), QWaylandSurfacePrivate::surface_commit(), QSSGLayerRenderPreparationResult::textureDimensions(), QVideoTextureHelper::SubtitleLayout::toImage(), QShapedPixmapWindow::updateGeometry(), QWasmScreen::updateQScreenAndCanvasRenderSize(), QQuickWidgetPrivate::updateSize(), and QVideoWindowPrivate::updateSubtitle().
|
noexcept |
Swaps the width and height values.
Definition at line 581 of file qsize.cpp.
References qSwap().
Referenced by QVideoFrame::paint().
|
inlineconstexprnoexcept |
Returns the size with width and height values swapped.
Definition at line 333 of file qsize.h.
References QSizeF().
Referenced by QXcbScreen::updateGeometry().
|
inlineconstexprnoexcept |
Returns the width.
Definition at line 321 of file qsize.h.
Referenced by QEglFSKmsScreen::QEglFSKmsScreen(), QQuickSelectionRectanglePrivate::QQuickSelectionRectanglePrivate(), _q_boundGeometryToSizeConstraints(), alignedRect(), QQuickLayoutPrivate::applySizeHints(), QGridLayoutItem::box(), QQuickBorderImagePrivate::calculateRects(), QQuickTableViewPrivate::calculateTopLeft(), QQuickTableViewPrivate::canLoadTableEdge(), centerOffset(), QBlitterPaintEnginePrivate::clipAndDrawPixmap(), closestAcceptableSize(), combineImplicitHints(), combineSize(), QQuickPaintedItem::contentsBoundingRect(), QQuickStyleItem::contentSize(), QQuickPopup::contentSizeChange(), QQuickScrollView::contentSizeChange(), QScrollerPrivate::createScrollingSegments(), QQuickColumn::doPositioning(), QQuickRow::doPositioning(), QQuickFlow::doPositioning(), QTextDocumentLayoutPrivate::drawBlock(), QMacStyle::drawControl(), QItemDelegate::drawDisplay(), QQuickLayout::dumpLayoutTreeRecursive(), QGridLayoutItem::effectiveMaxSize(), QGraphicsLayoutItemPrivate::effectiveSizeHints(), QScroller::ensureVisible(), getSize(), QQuickNinePatchNode::initialize(), QStyle::itemPixmapRect(), QQuickIconLabelPrivate::layout(), QTextDocumentLayoutPrivate::layoutBlock(), QTextDocumentLayoutPrivate::layoutFrame(), QQuickTableViewPrivate::layoutVerticalEdge(), marginsOffset(), QGraphicsLayoutItem::maximumWidth(), QQuickPdfDocument::maxPageWidth(), QPaintDeviceWindow::metric(), QWidget::metric(), QOpenGLWidget::metric(), QGraphicsLayoutItem::minimumWidth(), operator<<(), operator<<(), operator<<(), QSGSoftwareSpriteNode::paint(), QPagePreview::paintEvent(), QPlainTextEdit::paintEvent(), QScreen::physicalDotsPerInch(), QScreen::physicalDotsPerInchX(), QQC2::QWindowsXPStylePrivate::pixelMetricFromSystemDp(), QWindowsVistaStylePrivate::pixelMetricFromSystemDp(), QtWayland::TouchExtensionGlobal::postTouchEvent(), QGraphicsLayoutItem::preferredWidth(), QQuickBasePositioner::prePositioning(), QTextDocument::print(), QWindowsPrintDevice::printableMargins(), QSGOpenVGHelpers::qDrawBorderImage(), qt_convertUnits(), QSvgIOHandler::read(), QPdfIOHandler::read(), QSGSoftwareSpriteNode::rect(), QtGraphicsAnchorLayout::AnchorData::refreshSizeHints(), QQuickTableViewPrivate::relayoutTableItems(), QSGOpenVGSpriteNode::render(), QPdfDocument::render(), QTextDocumentLayout::resizeInlineObject(), QQuickTableViewPrivate::scrollTowardsSelectionPoint(), QScrollerPrivate::setContentPositionHelperDragging(), QQuickStyleItem::setContentWidth(), QPageLayoutPrivate::setDefaultMargins(), QWasmWindow::setGeometry(), QGraphicsAnchorLayoutPrivate::setItemsGeometries(), QQuickLayoutAttached::setMaximumImplicitSize(), QQuickLayoutAttached::setMinimumImplicitSize(), QPageLayout::setOrientation(), QWin32PrintEnginePrivate::setPageSize(), QQuickTextPrivate::signalSizeChange(), QLabelPrivate::sizeForWidth(), QGridLayoutEngine::sizeHint(), QQuickLayoutAttached::sizeHint(), QWindowsTheme::standardPixmap(), QItemDelegate::textRectangle(), to_d2d_size_u(), QQuickTableViewPrivate::updateAverageColumnWidth(), QQuickMultiEffectPrivate::updateBlurItemSizes(), QQuickTableViewPrivate::updateContentWidth(), QQuickTableViewPrivate::updateExtents(), QWin32PrintEnginePrivate::updateMetrics(), QQuickStyleItem::updatePaintNode(), QQuickNinePatchImagePrivate::updatePatches(), and QWasmScreen::updateQScreenAndCanvasRenderSize().
|
friend |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Multiplies the given size by the given finite factor and returns the result.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Multiplies the given size by the given finite factor and returns the result.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Divides the given size by the given divisor and returns the result.
The divisor must not be either zero or NaN.
|
related |
Returns true
if s1 and s2 are approximately equal; otherwise returns false.
|
related |
Reads a size from the given stream into the given size and returns a reference to the stream.
Definition at line 843 of file qsize.cpp.
References setHeight(), and setWidth().