Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
QRect Class Reference

\inmodule QtCore\reentrant More...

#include <qrect.h>

+ Collaboration diagram for QRect:

Public Member Functions

constexpr QRect () noexcept
 Constructs a null rectangle.
 
constexpr QRect (const QPoint &topleft, const QPoint &bottomright) noexcept
 Constructs a rectangle with the given topLeft and bottomRight corners, both included.
 
constexpr QRect (const QPoint &topleft, const QSize &size) noexcept
 Constructs a rectangle with the given topLeft corner and the given size.
 
constexpr QRect (int left, int top, int width, int height) noexcept
 Constructs a rectangle with (x, y) as its top-left corner and the given width and height.
 
constexpr bool isNull () const noexcept
 Returns true if the rectangle is a null rectangle, otherwise returns false.
 
constexpr bool isEmpty () const noexcept
 Returns true if the rectangle is empty, otherwise returns false.
 
constexpr bool isValid () const noexcept
 Returns true if the rectangle is valid, otherwise returns false.
 
constexpr int left () const noexcept
 Returns the x-coordinate of the rectangle's left edge.
 
constexpr int top () const noexcept
 Returns the y-coordinate of the rectangle's top edge.
 
constexpr int right () const noexcept
 Returns the x-coordinate of the rectangle's right edge.
 
constexpr int bottom () const noexcept
 Returns the y-coordinate of the rectangle's bottom edge.
 
QRect normalized () const noexcept
 Returns a normalized rectangle; i.e., a rectangle that has a non-negative width and height.
 
constexpr int x () const noexcept
 Returns the x-coordinate of the rectangle's left edge.
 
constexpr int y () const noexcept
 Returns the y-coordinate of the rectangle's top edge.
 
constexpr void setLeft (int pos) noexcept
 Sets the left edge of the rectangle to the given x coordinate.
 
constexpr void setTop (int pos) noexcept
 Sets the top edge of the rectangle to the given y coordinate.
 
constexpr void setRight (int pos) noexcept
 Sets the right edge of the rectangle to the given x coordinate.
 
constexpr void setBottom (int pos) noexcept
 Sets the bottom edge of the rectangle to the given y coordinate.
 
constexpr void setX (int x) noexcept
 Sets the left edge of the rectangle to the given x coordinate.
 
constexpr void setY (int y) noexcept
 Sets the top edge of the rectangle to the given y coordinate.
 
constexpr void setTopLeft (const QPoint &p) noexcept
 Set the top-left corner of the rectangle to the given position.
 
constexpr void setBottomRight (const QPoint &p) noexcept
 Set the bottom-right corner of the rectangle to the given position.
 
constexpr void setTopRight (const QPoint &p) noexcept
 Set the top-right corner of the rectangle to the given position.
 
constexpr void setBottomLeft (const QPoint &p) noexcept
 Set the bottom-left corner of the rectangle to the given position.
 
constexpr QPoint topLeft () const noexcept
 Returns the position of the rectangle's top-left corner.
 
constexpr QPoint bottomRight () const noexcept
 Returns the position of the rectangle's bottom-right corner.
 
constexpr QPoint topRight () const noexcept
 Returns the position of the rectangle's top-right corner.
 
constexpr QPoint bottomLeft () const noexcept
 Returns the position of the rectangle's bottom-left corner.
 
constexpr QPoint center () const noexcept
 Returns the center point of the rectangle.
 
constexpr void moveLeft (int pos) noexcept
 Moves the rectangle horizontally, leaving the rectangle's left edge at the given x coordinate.
 
constexpr void moveTop (int pos) noexcept
 Moves the rectangle vertically, leaving the rectangle's top edge at the given y coordinate.
 
constexpr void moveRight (int pos) noexcept
 Moves the rectangle horizontally, leaving the rectangle's right edge at the given x coordinate.
 
constexpr void moveBottom (int pos) noexcept
 Moves the rectangle vertically, leaving the rectangle's bottom edge at the given y coordinate.
 
constexpr void moveTopLeft (const QPoint &p) noexcept
 Moves the rectangle, leaving the top-left corner at the given position.
 
constexpr void moveBottomRight (const QPoint &p) noexcept
 Moves the rectangle, leaving the bottom-right corner at the given position.
 
constexpr void moveTopRight (const QPoint &p) noexcept
 Moves the rectangle, leaving the top-right corner at the given position.
 
constexpr void moveBottomLeft (const QPoint &p) noexcept
 Moves the rectangle, leaving the bottom-left corner at the given position.
 
constexpr void moveCenter (const QPoint &p) noexcept
 Moves the rectangle, leaving the center point at the given position.
 
constexpr void translate (int dx, int dy) noexcept
 Moves the rectangle dx along the x axis and dy along the y axis, relative to the current position.
 
constexpr void translate (const QPoint &p) noexcept
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Moves the rectangle {offset}.
 
constexpr QRect translated (int dx, int dy) const noexcept
 Returns a copy of the rectangle that is translated dx along the x axis and dy along the y axis, relative to the current position.
 
constexpr QRect translated (const QPoint &p) const 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 copy of the rectangle that is translated {offset}.
 
constexpr QRect transposed () const noexcept
 
constexpr void moveTo (int x, int t) noexcept
 Moves the rectangle, leaving the top-left corner at the given position (x, y).
 
constexpr void moveTo (const QPoint &p) noexcept
 Moves the rectangle, leaving the top-left corner at the given position.
 
constexpr void setRect (int x, int y, int w, int h) noexcept
 Sets the coordinates of the rectangle's top-left corner to ({x}, {y}), and its size to the given width and height.
 
constexpr void getRect (int *x, int *y, int *w, int *h) const
 Extracts the position of the rectangle's top-left corner to *x and *y, and its dimensions to *width and *height.
 
constexpr void setCoords (int x1, int y1, int x2, int y2) noexcept
 Sets the coordinates of the rectangle's top-left corner to (x1, y1), and the coordinates of its bottom-right corner to (x2, y2).
 
constexpr void getCoords (int *x1, int *y1, int *x2, int *y2) const
 Extracts the position of the rectangle's top-left corner to *x1 and *y1, and the position of the bottom-right corner to *x2 and *y2.
 
constexpr void adjust (int x1, int y1, int x2, int y2) noexcept
 Adds dx1, dy1, dx2 and dy2 respectively to the existing coordinates of the rectangle.
 
constexpr QRect adjusted (int x1, int y1, int x2, int y2) const noexcept
 Returns a new rectangle with dx1, dy1, dx2 and dy2 added respectively to the existing coordinates of this rectangle.
 
constexpr QSize size () const noexcept
 Returns the size of the rectangle.
 
constexpr int width () const noexcept
 Returns the width of the rectangle.
 
constexpr int height () const noexcept
 Returns the height of the rectangle.
 
constexpr void setWidth (int w) noexcept
 Sets the width of the rectangle to the given width.
 
constexpr void setHeight (int h) noexcept
 Sets the height of the rectangle to the given height.
 
constexpr void setSize (const QSize &s) noexcept
 Sets the size of the rectangle to the given size.
 
QRect operator| (const QRect &r) const noexcept
 Returns the bounding rectangle of this rectangle and the given rectangle.
 
QRect operator& (const QRect &r) const noexcept
 Returns the intersection of this rectangle and the given rectangle.
 
QRectoperator|= (const QRect &r) noexcept
 Unites this rectangle with the given rectangle.
 
QRectoperator&= (const QRect &r) noexcept
 Intersects this rectangle with the given rectangle.
 
bool contains (const QRect &r, bool proper=false) const noexcept
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Returns true if the given rectangle is inside this rectangle.
 
bool contains (const QPoint &p, bool proper=false) const noexcept
 Returns true if the given point is inside or on the edge of the rectangle, otherwise returns false.
 
bool contains (int x, int y) const noexcept
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Returns true if the point (x, y) is inside this rectangle, otherwise returns false.
 
bool contains (int x, int y, bool proper) const noexcept
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Returns true if the point (x, y) is inside or on the edge of the rectangle, otherwise returns false.
 
QRect united (const QRect &other) const noexcept
 
QRect intersected (const QRect &other) const noexcept
 
bool intersects (const QRect &r) const noexcept
 Returns true if this rectangle intersects with the given rectangle (i.e., there is at least one pixel that is within both rectangles), otherwise returns false.
 
constexpr QRect marginsAdded (const QMargins &margins) const noexcept
 Returns a rectangle grown by the margins.
 
constexpr QRect marginsRemoved (const QMargins &margins) const noexcept
 Removes the margins from the rectangle, shrinking it.
 
constexpr QRectoperator+= (const QMargins &margins) noexcept
 Adds the margins to the rectangle, growing it.
 
constexpr QRectoperator-= (const QMargins &margins) noexcept
 Returns a rectangle shrunk by the margins.
 
constexpr QRectF toRectF () const noexcept
 

Static Public Member Functions

static constexpr QRect span (const QPoint &p1, const QPoint &p2) noexcept
 Returns a rectangle spanning the two points p1 and p2, including both and everything in between.
 

Friends

constexpr bool operator== (const QRect &r1, const QRect &r2) noexcept
 Returns true if the rectangles r1 and r2 are equal, otherwise returns false.
 
constexpr bool operator!= (const QRect &r1, const QRect &r2) noexcept
 Returns true if the rectangles r1 and r2 are different, otherwise returns false.
 
constexpr size_t qHash (const QRect &, size_t) noexcept
 

Related Symbols

(Note that these are not member symbols.)

QRect operator+ (const QRect &rectangle, const QMargins &margins)
 Returns the rectangle grown by the margins.
 
QRect operator+ (const QMargins &margins, const QRect &rectangle)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Returns the rectangle grown by the margins.
 
QRect operator- (const QRect &lhs, const QMargins &rhs)
 Returns the lhs rectangle shrunk by the rhs margins.
 
QDataStreamoperator<< (QDataStream &stream, const QRect &rectangle)
 Writes the given rectangle to the given stream, and returns a reference to the stream.
 
QDataStreamoperator>> (QDataStream &stream, QRect &rectangle)
 Reads a rectangle from the given stream into the given rectangle, and returns a reference to the stream.
 

Detailed Description

\inmodule QtCore

\reentrant

The QRect class defines a rectangle in the plane using integer precision.

A rectangle is normally expressed as a top-left corner and a size. The size (width and height) of a QRect is always equivalent to the mathematical rectangle that forms the basis for its rendering.

A QRect can be constructed with a set of left, top, width and height integers, or from a QPoint and a QSize. The following code creates two identical rectangles.

QRect r1(100, 200, 11, 16);
QRect r2(QPoint(100, 200), QSize(11, 16));

There is a third constructor that creates a QRect using the top-left and bottom-right coordinates, but we recommend that you avoid using it. The rationale is that for historical reasons the values returned by the bottom() and right() functions deviate from the true bottom-right corner of the rectangle.

The QRect class provides a collection of functions that return the various rectangle coordinates, and enable manipulation of these. QRect also provides functions to move the rectangle relative to the various coordinates. In addition there is a moveTo() function that moves the rectangle, leaving its top left corner at the given coordinates. Alternatively, the translate() function moves the rectangle the given offset relative to the current position, and the translated() function returns a translated copy of this rectangle.

The size() function returns the rectangle's dimensions as a QSize. The dimensions can also be retrieved separately using the width() and height() functions. To manipulate the dimensions use the setSize(), setWidth() or setHeight() functions. Alternatively, the size can be changed by applying either of the functions setting the rectangle coordinates, for example, setBottom() or setRight().

The contains() function tells whether a given point is inside the rectangle or not, and the intersects() function returns true if this rectangle intersects with a given rectangle. The QRect class also provides the intersected() function which returns the intersection rectangle, and the united() function which returns the rectangle that encloses the given rectangle and this:

\table \row

The isEmpty() function returns true if left() > right() or top() > bottom(). Note that an empty rectangle is not valid: The isValid() function returns true if left() <= right() and top() <= bottom(). A null rectangle (isNull() == true) on the other hand, has both width and height set to 0.

Note that due to the way QRect and QRectF are defined, an empty QRect is defined in essentially the same way as QRectF.

Finally, QRect objects can be streamed as well as compared.

Definition at line 29 of file qrect.h.

Constructor & Destructor Documentation

◆ QRect() [1/4]

QRect::QRect ( )
inlineconstexprnoexcept

Constructs a null rectangle.

See also
isNull()

Definition at line 32 of file qrect.h.

◆ QRect() [2/4]

constexpr QRect::QRect ( const QPoint & topLeft,
const QPoint & bottomRight )
inlineconstexprnoexcept

Constructs a rectangle with the given topLeft and bottomRight corners, both included.

If bottomRight is to higher and to the left of topLeft, the rectangle defined is instead non-inclusive of the corners.

Note
To ensure both points are included regardless of relative order, use span().
See also
setTopLeft(), setBottomRight(), span()

Definition at line 157 of file qrect.h.

◆ QRect() [3/4]

constexpr QRect::QRect ( const QPoint & topLeft,
const QSize & size )
inlineconstexprnoexcept

Constructs a rectangle with the given topLeft corner and the given size.

See also
setTopLeft(), setSize()

Definition at line 160 of file qrect.h.

◆ QRect() [4/4]

constexpr QRect::QRect ( int x,
int y,
int width,
int height )
inlineconstexprnoexcept

Constructs a rectangle with (x, y) as its top-left corner and the given width and height.

See also
setRect()

Definition at line 154 of file qrect.h.

Member Function Documentation

◆ adjust()

constexpr void QRect::adjust ( int dx1,
int dy1,
int dx2,
int dy2 )
inlineconstexprnoexcept

Adds dx1, dy1, dx2 and dy2 respectively to the existing coordinates of the rectangle.

See also
adjusted(), setRect()

Definition at line 372 of file qrect.h.

Referenced by QSvgFeGaussianBlur::apply(), dockedGeometry(), QLabelPrivate::documentRect(), QItemDelegate::doLayout(), QQC2::QCommonStyle::drawComplexControl(), QCommonStyle::drawComplexControl(), QAndroidStyle::drawComplexControl(), QQC2::QWindowsXPStyle::drawComplexControl(), QWindowsVistaStyle::drawComplexControl(), QQC2_NAMESPACE::QMacStyle::drawControl(), QMacStyle::drawControl(), QQC2::QWindowsXPStyle::drawControl(), QWindowsVistaStyle::drawControl(), QPixmapStyle::drawControl(), QGraphicsScenePrivate::drawItemHelper(), QQC2_NAMESPACE::QMacStyle::drawPrimitive(), QQC2::QCommonStyle::drawPrimitive(), QMacStyle::drawPrimitive(), QCommonStyle::drawPrimitive(), QGraphicsScenePrivate::drawSubtreeRecursive(), QDockAreaLayout::findSeparator(), QMenuBarPrivate::menuRect(), QDockWidgetPrivate::nonClientAreaMouseEvent(), QQuickUniversalFocusRectangle::paint(), QLabel::paintEvent(), QGraphicsWidget::paintWindowFrame(), QListViewPrivate::prepareItemsLayout(), QFrame::setFrameRect(), QFormLayout::setGeometry(), QMdiSubWindowPrivate::setMaximizeMode(), QTabBarPrivate::setupMovableTab(), QAndroidStyle::subControlRect(), QQC2_NAMESPACE::QMacStyle::subElementRect(), QQC2::QCommonStyle::subElementRect(), QMacStyle::subElementRect(), QCommonStyle::subElementRect(), QPlainTextEdit::timerEvent(), QTextEdit::timerEvent(), QGraphicsViewPrivate::updateRegion(), and QGraphicsView::updateScene().

+ Here is the caller graph for this function:

◆ adjusted()

constexpr QRect QRect::adjusted ( int dx1,
int dy1,
int dx2,
int dy2 ) const
inlineconstexprnoexcept

Returns a new rectangle with dx1, dy1, dx2 and dy2 added respectively to the existing coordinates of this rectangle.

See also
adjust()

Definition at line 369 of file qrect.h.

Referenced by QSGRhiAtlasTexture::Texture::atlasSubRectWithoutPadding(), QWidgetPrivate::checkRestoredGeometry(), QSvgFeFilterPrimitive::clipToTransformedBounds(), QPainterPrivate::draw_helper(), QQC2_NAMESPACE::QMacStyle::drawComplexControl(), QQC2::QWindowsStyle::drawComplexControl(), QMacStyle::drawComplexControl(), QQC2::QWindowsXPStyle::drawComplexControl(), QWindows11Style::drawComplexControl(), QWindowsVistaStyle::drawComplexControl(), QSplashScreen::drawContents(), QAndroidStyle::AndroidControl::drawControl(), QQC2_NAMESPACE::QMacStyle::drawControl(), QQC2::QCommonStyle::drawControl(), QQC2::QWindowsStyle::drawControl(), QMacStyle::drawControl(), QCommonStyle::drawControl(), QQC2::QWindowsXPStyle::drawControl(), QWindows11Style::drawControl(), QWindowsVistaStyle::drawControl(), QItemDelegate::drawDisplay(), QGraphicsScenePrivate::drawItemHelper(), QGraphicsScenePrivate::drawItems(), QWindowsVistaStyle::drawPrimitive(), QQC2_NAMESPACE::QMacStyle::drawPrimitive(), QQC2::QCommonStyle::drawPrimitive(), QQC2::QWindowsStyle::drawPrimitive(), QMacStyle::drawPrimitive(), QCommonStyle::drawPrimitive(), QQC2_NAMESPACE::drawTabShape(), QGraphicsViewPrivate::findItems(), QToolBarAreaLayout::fitLayout(), QGraphicsView::mapToScene(), QListView::mouseMoveEvent(), QListView::mouseReleaseEvent(), QtPrivate::QWellArray::paintCell(), QPagePreview::paintEvent(), QFocusFrame::paintEvent(), QPlainTextEdit::paintEvent(), QGraphicsView::render(), QOutlineMapper::setClipRect(), QQC2::QWindowsStyle::styleHint(), QCommonStyle::styleHint(), QQC2::QCommonStyle::styleHint(), QQC2_NAMESPACE::QMacStyle::subControlRect(), QQC2::QCommonStyle::subControlRect(), QMacStyle::subControlRect(), QCommonStyle::subControlRect(), QAndroidStyle::subControlRect(), QWindows11Style::subElementRect(), QWindowsVistaStyle::subElementRect(), QQC2_NAMESPACE::QMacStyle::subElementRect(), QQC2::QCommonStyle::subElementRect(), QCommonStyle::subElementRect(), QAndroidStyle::AndroidControl::subElementRect(), QAndroidStyle::AndroidProgressBarControl::subElementRect(), QCommandLinkButtonPrivate::titleRect(), QCommonListViewBase::verticalScrollToValue(), and src_gui_painting_qpainter2::MyWidget::wrapper15().

◆ bottom()

constexpr int QRect::bottom ( ) const
inlineconstexprnoexcept

Returns the y-coordinate of the rectangle's bottom edge.

Note that for historical reasons this function returns top() + height() - 1; use y() + height() to retrieve the true y-coordinate.

See also
setBottom(), bottomLeft(), bottomRight()

Definition at line 181 of file qrect.h.

Referenced by QSpanBuffer::addSpan(), QWaylandXdgPositionerData::anchorPoint(), QDockAreaLayoutInfo::apply(), QToolBarAreaLayout::apply(), QWindowGeometrySpecification::applyTo(), QCommonStylePrivate::calculateElidedText(), QQC2::QCommonStylePrivate::calculateElidedText(), QGroupBoxPrivate::calculateFrame(), QWidgetPrivate::checkRestoredGeometry(), clipStraightLine(), QDockAreaLayout::constrainedRect(), QWaylandQtShellChromePrivate::constrainPoint(), RenderHelpers::correctViewportCoordinates(), QToolBarAreaLayoutInfo::distance(), QGridLayoutPrivate::distribute(), QLabelPrivate::documentRect(), QAndroidStyle::Android9PatchDrawable::draw(), QQC2_NAMESPACE::QMacStyle::drawControl(), QQC2::QCommonStyle::drawControl(), QQC2::QWindowsStyle::drawControl(), QMacStyle::drawControl(), QCommonStyle::drawControl(), QWindows11Style::drawControl(), QWindowsVistaStyle::drawControl(), QQC2_NAMESPACE::QMacStyle::drawPrimitive(), QQC2::QCommonStyle::drawPrimitive(), QMacStyle::drawPrimitive(), QCommonStyle::drawPrimitive(), QMacStylePrivate::drawToolbarButtonArrow(), QTreeView::drawTree(), QPlainTextEditPrivate::ensureCursorVisible(), QRasterPaintEngine::fillPath(), QToolBarAreaLayoutInfo::fitLayout(), QWidget::frameGeometry(), QWidget::frameSize(), QDockAreaLayout::gapRect(), QDockAreaLayout::getGrid(), QIntersectionFinder::hasIntersections(), QRasterPaintEnginePrivate::isUnclipped(), QRasterPaintEnginePrivate::isUnclipped_normalized(), QWidgetResizeHandler::keyPressEvent(), QTabBarPrivate::makeVisible(), QWidgetResizeHandler::mouseMoveEvent(), QComboBoxPrivateScroller::mouseMoveEvent(), QSizeGrip::mousePressEvent(), QListView::moveCursor(), QAbstractButtonPrivate::moveFocus(), operator<<(), QtWaylandClient::QWaylandBradientDecoration::paint(), QTabBar::paintEvent(), QMenuBarPrivate::popupAction(), QDateTimeEditPrivate::positionCalendarPopup(), QSGBatchRenderer::Renderer::prepareRenderPass(), QQC2::qDrawBorderPixmap(), QSGSoftwareHelpers::qDrawBorderPixmap(), qRectIntersects(), qt_intersect_spans(), qt_scrollRectInImage(), QRasterizer::rasterize(), QRasterizer::rasterize(), QRasterizer::rasterizeLine(), read_jpeg_image(), QMdi::RegularTiler::rearrange(), rect_intersects(), QPdfDocument::render(), QAndroidPlatformWindow::safeAreaMargins(), QListViewPrivate::scrollElasticBandBy(), QMenuPrivate::scrollMenu(), QFrame::setFrameRect(), QDockWidgetLayout::setGeometry(), QDockAreaLayout::setGrid(), QWidgetPrivate::setLayoutItemMargins(), QMenu::sizeHint(), QPlainTextEdit::timerEvent(), QTextEdit::timerEvent(), QWaylandQtShellChromePrivate::updateDecorationInteraction(), QFramePrivate::updateStyledFrameWidths(), useScrollBar(), QCommonListViewBase::verticalScrollToValue(), and QTreeView::visualRegionForSelection().

◆ bottomLeft()

constexpr QPoint QRect::bottomLeft ( ) const
inlineconstexprnoexcept

Returns the position of the rectangle's bottom-left corner.

Note that for historical reasons this function returns QPoint(left(), top() + height() - 1).

See also
setBottomLeft(), bottom(), left()

Definition at line 229 of file qrect.h.

Referenced by QQC2_NAMESPACE::QMacStyle::drawControl(), QQC2::QWindowsStyle::drawControl(), QMacStyle::drawControl(), QQC2_NAMESPACE::QMacStyle::drawPrimitive(), QMacStyle::drawPrimitive(), QDialog::resizeEvent(), and QDialog::setSizeGripEnabled().

+ Here is the caller graph for this function:

◆ bottomRight()

constexpr QPoint QRect::bottomRight ( ) const
inlineconstexprnoexcept

Returns the position of the rectangle's bottom-right corner.

Note that for historical reasons this function returns QPoint(left() + width() -1, top() + height() - 1).

See also
setBottomRight(), bottom(), right()

Definition at line 223 of file qrect.h.

Referenced by QWidgetResizeHandler::doResize(), QQC2::QWindowsStyle::drawControl(), QQC2_NAMESPACE::QMacStyle::drawPrimitive(), QQC2::QCommonStyle::drawPrimitive(), QMacStyle::drawPrimitive(), QCommonStyle::drawPrimitive(), QWidgetResizeHandler::eventFilter(), QWidgetResizeHandler::mouseMoveEvent(), QRasterizer::rasterizeLine(), QDialog::resizeEvent(), and QDialog::setSizeGripEnabled().

+ Here is the caller graph for this function:

◆ center()

◆ contains() [1/4]

bool QRect::contains ( const QPoint & point,
bool proper = false ) const
noexcept

Returns true if the given point is inside or on the edge of the rectangle, otherwise returns false.

If proper is true, this function only returns true if the given point is inside the rectangle (i.e., not on the edge).

See also
intersects()

Definition at line 787 of file qrect.cpp.

◆ contains() [2/4]

bool QRect::contains ( const QRect & rectangle,
bool proper = false ) const
noexcept

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Returns true if the given rectangle is inside this rectangle.

otherwise returns false. If proper is true, this function only returns true if the rectangle is entirely inside this rectangle (not on the edge).

Definition at line 851 of file qrect.cpp.

References r1, r2, and t2.

Referenced by _q_paintIntoCache(), QMenuBarPrivate::actionAt(), QWidgetPrivate::checkRestoredGeometry(), childWindowAt(), QApplicationPrivate::closePopup(), QPathClipper::contains(), QQuickMaskExtruder::contains(), QDialog::contextMenuEvent(), QWindowsOleDropTarget::DragOver(), QTipLabel::eventFilter(), QCalendarWidget::eventFilter(), QImageTextureGlyphCache::fillTexture(), QDockAreaLayout::findSeparator(), QToolBarAreaLayoutInfo::gapIndex(), QColorDialogPrivate::handleColorPickingMouseMove(), QEglFSScreen::handleCursorMove(), QWidgetWindow::handleMouseEvent(), QAbstractButton::hitButton(), QPathClipper::intersect(), QDockWidgetPrivate::mouseDoubleClickEvent(), QMenu::mouseMoveEvent(), QWidgetResizeHandler::mouseMoveEvent(), QTipLabel::mouseMoveEvent(), QPlainTextEdit::mouseMoveEvent(), QTextEdit::mouseMoveEvent(), QMenu::mousePressEvent(), QDockWidgetPrivate::mousePressEvent(), MainWindow::mousePressEvent(), QXcbDrag::move(), QDockWidgetPrivate::nonClientAreaMouseEvent(), QRhiD3D::output6ForWindow(), QMenuPrivate::popup(), QPlatformWindow::screenForGeometry(), QWindowPrivate::screenForGeometry(), QPlatformScreen::screenForPosition(), QWaylandSurfacePrivate::surface_commit(), QTabBar::tabAt(), QTipLabel::tipChanged(), QWasmScreen::topLevelAt(), QQnxScreen::topLevelAt(), QMenuBarPrivate::updateGeometries(), QGraphicsWidget::windowFrameSectionAt(), and windowInteractsWithPosition().

+ Here is the caller graph for this function:

◆ contains() [3/4]

bool QRect::contains ( int x,
int y ) const
inlinenoexcept

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Returns true if the point (x, y) is inside this rectangle, otherwise returns false.

Definition at line 397 of file qrect.h.

References contains().

+ Here is the call graph for this function:

◆ contains() [4/4]

bool QRect::contains ( int x,
int y,
bool proper ) const
inlinenoexcept

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Returns true if the point (x, y) is inside or on the edge of the rectangle, otherwise returns false.

If proper is true, this function only returns true if the point is entirely inside the rectangle(not on the edge).

Definition at line 392 of file qrect.h.

References contains().

+ Here is the call graph for this function:

◆ getCoords()

constexpr void QRect::getCoords ( int * x1,
int * y1,
int * x2,
int * y2 ) const
inlineconstexpr

Extracts the position of the rectangle's top-left corner to *x1 and *y1, and the position of the bottom-right corner to *x2 and *y2.

See also
setCoords(), getRect()

Definition at line 353 of file qrect.h.

◆ getRect()

constexpr void QRect::getRect ( int * x,
int * y,
int * width,
int * height ) const
inlineconstexpr

Extracts the position of the rectangle's top-left corner to *x and *y, and its dimensions to *width and *height.

See also
setRect(), getCoords()

Definition at line 337 of file qrect.h.

Referenced by QQC2::QCommonStyle::drawControl(), QCommonStyle::drawControl(), QStyle::itemPixmapRect(), QQC2::QStyle::itemPixmapRect(), QStyle::itemTextRect(), and QQC2::QStyle::itemTextRect().

+ Here is the caller graph for this function:

◆ height()

constexpr int QRect::height ( ) const
inlineconstexprnoexcept

Returns the height of the rectangle.

See also
setHeight(), width(), size()

Definition at line 238 of file qrect.h.

Referenced by QVncDirtyMap::QVncDirtyMap(), QWindowCreationContext::QWindowCreationContext(), QPrintPreviewWidgetPrivate::_q_fit(), QWaylandXdgPositionerData::anchorPoint(), QDockAreaLayoutInfo::apply(), QQnxScreen::availableGeometry(), QPainter::begin(), QOpenGLFramebufferObject::blitFramebuffer(), QGraphicsItem::boundingRegion(), QPrintPreviewWidgetPrivate::calcCurrentPage(), QCommonStylePrivate::calculateElidedText(), QQC2::QCommonStylePrivate::calculateElidedText(), QAndroidPlatformOpenGLWindow::checkNativeSurface(), QWidgetPrivate::checkRestoredGeometry(), clippedBlit(), QQC2_NAMESPACE::cocoaControlType(), cocoaControlType(), QWaylandQtShellSurfacePrivate::configure(), QDockAreaLayout::constrainedRect(), QPathClipper::contains(), correctMVPForScissor(), QQuickContext2DTile::createPainter(), QItemDelegate::doLayout(), QAndroidStyle::AndroidImageDrawable::draw(), QAndroidStyle::AndroidGradientDrawable::draw(), QWindowsVistaStylePrivate::drawBackgroundThruNativeBuffer(), QQC2::QWindowsXPStylePrivate::drawBackgroundThruNativeBuffer(), QQC2_NAMESPACE::QMacStyle::drawComplexControl(), QMacStyle::drawComplexControl(), QQC2_NAMESPACE::QMacStyle::drawControl(), QQC2::QCommonStyle::drawControl(), QQC2::QWindowsStyle::drawControl(), QMacStyle::drawControl(), QCommonStyle::drawControl(), QQC2::QWindowsXPStyle::drawControl(), QWindows11Style::drawControl(), QWindowsVistaStyle::drawControl(), QItemDelegate::drawDisplay(), dom::drawImageToWebImageDataArray(), QGraphicsScenePrivate::drawItemHelper(), QQC2_NAMESPACE::QMacStyle::drawPrimitive(), QQC2::QCommonStyle::drawPrimitive(), QQC2::QWindowsStyle::drawPrimitive(), QAndroidStyle::drawPrimitive(), QMacStyle::drawPrimitive(), QCommonStyle::drawPrimitive(), QPaintEngine::drawRects(), QPainter::drawRects(), QQC2_NAMESPACE::drawTabBase(), QQC2_NAMESPACE::drawTabShape(), dumpNativeWindowsRecursion(), QOutlineMapper::endOutline(), QDockAreaLayout::fitLayout(), QWindowsBackingStore::flush(), QXcbNativeBackingStore::flush(), QWindowsDirect2DWindow::flush(), QDockAreaLayout::gapRect(), QDockAreaLayout::getGrid(), QBsdFbScreen::grabWindow(), QEglFSScreen::grabWindow(), QIntegrityFbScreen::grabWindow(), QLinuxFbScreen::grabWindow(), QVncScreen::grabWindow(), QOffscreenBackingStore::grabWindow(), QOffscreenScreen::grabWindow(), QQnxScreen::grabWindow(), QBsdFbScreen::initialize(), QLinuxFbScreen::initialize(), QVncScreen::initialize(), QSpanData::initTexture(), QColorDialogPrivate::initWidgets(), QPathClipper::intersect(), QQnxInputContext::keyboardRect(), QMdiSubWindow::keyPressEvent(), QPicture::metric(), QPaintDeviceWindow::metric(), QWidget::metric(), QOpenGLWidget::metric(), QSizeGrip::mousePressEvent(), QTabBar::mouseReleaseEvent(), QListView::moveCursor(), QTableView::moveCursor(), operator<<(), operator<<(), QIOSScreen::orientation(), QPdfEnginePrivate::pageMatrix(), QSGOpenVGPainterNode::paint(), QSGSoftwarePainterNode::paint(), QSGDefaultPainterNode::paint(), QtWaylandClient::QWaylandBradientDecoration::paint(), QSGSoftwareInternalRectangleNode::paint(), QmlJSDebugger::SelectionHighlight::paint(), QFontFamilyDelegate::paint(), QPagePreview::paintEvent(), QLabel::paintEvent(), QPlainTextEdit::paintEvent(), QTipLabel::placeTip(), QMenuPrivate::popup(), QLineEditPrivate::positionSideWidgets(), QQuick3DSGRenderNode::prepare(), prepareDrawForRenderToTextureWidget(), QWindowsDirect2DWindow::present(), qDrawRoundedCorners(), qNormalizeRadii(), qt_scrollRectInImage(), qt_transform_image_rasterize(), QRasterPaintEnginePrivate::rasterize(), read_jpeg_image(), QMdi::RegularTiler::rearrange(), QMdi::SimpleCascader::rearrange(), QMdi::IconTiler::rearrange(), QGraphicsView::render(), QSGRhiDistanceFieldGlyphCache::requestGlyphs(), QXcbNativeBackingStore::resize(), QMdiAreaPrivate::resizeToMinimumTileSize(), QQC2_NAMESPACE::rotateTabPainter(), QAlphaWidget::run(), QDockAreaLayoutInfo::saveState(), QWhatsThisPrivate::say(), QQC2::QWindowsXPStylePrivate::scrollBarGripperBounds(), QMenuPrivate::scrollMenu(), QMenuPrivate::scrollMenu(), QAndroidPlatformScreen::setAvailableGeometry(), QPolygonClipper< InType, OutType, CastType >::setBoundingRect(), QWindowsWindow::setCustomMargins(), setDisplayMetrics(), QMenuPrivate::setFirstActionActive(), QBoxLayout::setGeometry(), QDockWidgetLayout::setGeometry(), QAndroidPlatformOpenGLWindow::setGeometry(), QAndroidPlatformVulkanWindow::setGeometry(), QFormLayout::setGeometry(), QMdiSubWindowPrivate::setMaximizeMode(), QMdiSubWindowPrivate::setNewGeometry(), QQnxScreen::setRotation(), QLinuxMediaDevice::setSubdevSelection(), QAndroidPlatformWindow::setVisible(), QtAndroidMenu::showContextMenu(), QCocoaMenu::showPopup(), QLabelPrivate::sizeForWidth(), QAndroidStyle::sizeFromContents(), QMenu::sizeHint(), QMenuBar::sizeHint(), QQC2_NAMESPACE::QMacStyle::subControlRect(), QQC2::QCommonStyle::subControlRect(), QMacStyle::subControlRect(), QCommonStyle::subControlRect(), QAndroidStyle::subControlRect(), QWindowsVistaStyle::subElementRect(), QQC2_NAMESPACE::QMacStyle::subElementRect(), QQC2::QCommonStyle::subElementRect(), QMacStyle::subElementRect(), QCommonStyle::subElementRect(), QPlainTextEdit::timerEvent(), QTextEdit::timerEvent(), QTableView::timerEvent(), QTreeView::timerEvent(), QMdiSubWindowPrivate::titleBarHeight(), QtWaylandClient::QWaylandScreen::toScreenOrientation(), QWindowsMouseHandler::translateTouchEvent(), QSGSoftwareInternalRectangleNode::update(), QMenuPrivate::updateActionRects(), QMenuBarPrivate::updateGeometries(), QTableView::updateGeometries(), QWin32PrintEnginePrivate::updateMetrics(), QScreenPrivate::updatePrimaryOrientation(), QIOSScreen::updateProperties(), QMdiAreaPrivate::updateScrollBars(), QQuickTreeViewPrivate::updateSelection(), QWasmVideoOutput::updateVideoElementGeometry(), updateWindow(), useScrollBar(), and QCommonListViewBase::verticalScrollToValue().

◆ intersected()

QRect QRect::intersected ( const QRect & rectangle) const
inlinenoexcept
Since
4.2

Returns the intersection of this rectangle and the given rectangle. Note that {r.intersected(s)} is equivalent to {r & s}.

See also
intersects(), united(), operator&=()

Definition at line 414 of file qrect.h.

References other().

Referenced by adjustedArea(), QSvgFeColorMatrix::apply(), QSvgFeMerge::apply(), QSvgFeComposite::apply(), QQnxRasterWindow::blitPreviousToCurrent(), QOpenGL2PaintEngineEx::clip(), QQuickContext2DImageTexture::compositeTile(), convolute(), QPixmapBlurFilter::draw(), QPixmapColorizeFilter::draw(), QPainterPrivate::draw_helper(), QQC2::QCommonStyle::drawControl(), QCommonStyle::drawControl(), QRasterPaintEngine::drawImage(), QStyle::drawItemPixmap(), QQC2::QStyle::drawItemPixmap(), QRasterPaintEngine::drawPixmap(), QBlitterPaintEngine::fillRect(), QBlitterPaintEnginePrivate::fillRect(), QCocoaScreen::grabWindow(), QRasterPaintEnginePrivate::initializeRasterizer(), QAbstractItemViewPrivate::intersectedRect(), QTableViewPrivate::intersectedRect(), QWidgetPrivate::moveRect(), QQuickContext2DTexture::paint(), src_gui_painting_qregion::MyWidget::paintEvent(), QListView::paintEvent(), qt_scrollRectInImage(), read_jpeg_image(), QVideoWindowPrivate::render(), QXcbNativeBackingStore::resize(), QFbScreen::setDirty(), QQuickContext2DTexture::setDirtyRect(), QRasterPlatformPixmap::toImage(), QSGSoftwareRenderableNode::update(), QOpenGL2PaintEngineExPrivate::updateClipScissorTest(), QItemDelegate::updateEditorGeometry(), and src_gui_painting_qregion_unix::wrapper().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ intersects()

bool QRect::intersects ( const QRect & rectangle) const
noexcept

Returns true if this rectangle intersects with the given rectangle (i.e., there is at least one pixel that is within both rectangles), otherwise returns false.

The intersection rectangle can be retrieved using the intersected() function.

See also
contains()

Definition at line 1065 of file qrect.cpp.

References r1, r2, and t2.

Referenced by QFbCursor::changeCursor(), QOutlineMapper::curveTo(), QAbstractItemViewPrivate::draggablePaintPairs(), QWidgetResizeHandler::mouseMoveEvent(), QMenu::paintEvent(), QMenuBar::paintEvent(), QMenuPrivate::ScrollerTearOffItem::paintEvent(), QFbCursor::pointerEvent(), QPlatformWindow::screenForGeometry(), QWindowPrivate::screenForGeometry(), QGraphicsItem::scroll(), QFbCursor::setPos(), QGraphicsView::updateScene(), QListView::visualRegionForSelection(), QTableView::visualRegionForSelection(), and QTreeView::visualRegionForSelection().

+ Here is the caller graph for this function:

◆ isEmpty()

constexpr bool QRect::isEmpty ( ) const
inlineconstexprnoexcept

◆ isNull()

constexpr bool QRect::isNull ( ) const
inlineconstexprnoexcept

◆ isValid()

constexpr bool QRect::isValid ( ) const
inlineconstexprnoexcept

◆ left()

constexpr int QRect::left ( ) const
inlineconstexprnoexcept

Returns the x-coordinate of the rectangle's left edge.

Equivalent to x().

See also
setLeft(), topLeft(), bottomLeft()

Definition at line 172 of file qrect.h.

Referenced by QSpanBuffer::addSpan(), QWaylandXdgPositionerData::anchorPoint(), QDockAreaLayoutInfo::apply(), QWindowGeometrySpecification::applyTo(), QPicturePaintEngine::begin(), QOpenGLFramebufferObject::blitFramebuffer(), QGroupBoxPrivate::calculateFrame(), QWidgetPrivate::checkRestoredGeometry(), clipStraightLine(), QDockAreaLayout::constrainedRect(), QWaylandQtShellChromePrivate::constrainPoint(), QQuickContext2DTile::createPainter(), QToolBarAreaLayoutInfo::distance(), QLabelPrivate::documentRect(), QLayoutPrivate::doResize(), QAndroidStyle::Android9PatchDrawable::draw(), QQC2_NAMESPACE::QMacStyle::drawControl(), QQC2::QCommonStyle::drawControl(), QQC2::QWindowsStyle::drawControl(), QMacStyle::drawControl(), QCommonStyle::drawControl(), QWindowsVistaStyle::drawControl(), QGraphicsScenePrivate::drawItemHelper(), QQC2_NAMESPACE::QMacStyle::drawPrimitive(), QQC2::QCommonStyle::drawPrimitive(), QMacStyle::drawPrimitive(), QCommonStyle::drawPrimitive(), QPlainTextEditPrivate::ensureCursorVisible(), QRasterPaintEngine::fillPath(), QDockAreaLayout::fitLayout(), QToolBarAreaLayoutInfo::fitLayout(), QToolBarAreaLayout::fitLayout(), QWidget::frameGeometry(), QWidget::frameSize(), QDockAreaLayout::gapRect(), QDockAreaLayout::getGrid(), QIntersectionFinder::hasIntersections(), if(), QRasterPaintEnginePrivate::isUnclipped(), QRasterPaintEnginePrivate::isUnclipped_normalized(), QWidgetResizeHandler::keyPressEvent(), QTabBarPrivate::makeVisible(), QWidgetResizeHandler::mouseMoveEvent(), QTabBar::paintEvent(), QDateTimeEditPrivate::positionCalendarPopup(), QWindowsDirect2DWindow::present(), QQC2::qDrawBorderPixmap(), QSGSoftwareHelpers::qDrawBorderPixmap(), QRectF_intersects(), qRectIntersects(), qt_intersect_spans(), qt_scrollRectInImage(), qt_transform_image_rasterize(), QRasterizer::rasterize(), QRasterizer::rasterize(), QRasterizer::rasterizeLine(), rect_intersects(), QPdfDocument::render(), QGraphicsView::render(), QAndroidPlatformWindow::safeAreaMargins(), QListViewPrivate::scrollElasticBandBy(), setDisplayMetrics(), EvrVideoWindowControl::setDisplayRect(), QFrame::setFrameRect(), QDockAreaLayout::setGrid(), QWidgetPrivate::setLayoutItemMargins(), QLinuxMediaDevice::setSubdevSelection(), QQC2::QCommonStyle::subElementRect(), QCommonStyle::subElementRect(), QPlainTextEdit::timerEvent(), QTextEdit::timerEvent(), QWaylandQtShellChromePrivate::updateDecorationInteraction(), QMenuBarPrivate::updateGeometries(), QTableView::updateGeometries(), QTreeView::updateGeometries(), QMdiAreaPrivate::updateScrollBars(), QFramePrivate::updateStyledFrameWidths(), QWasmVideoOutput::updateVideoElementGeometry(), and useScrollBar().

◆ marginsAdded()

constexpr QRect QRect::marginsAdded ( const QMargins & margins) const
inlineconstexprnoexcept

Returns a rectangle grown by the margins.

See also
operator+=(), marginsRemoved(), operator-=()
Since
5.1

Definition at line 447 of file qrect.h.

Referenced by QWidgetResizeHandler::eventFilter().

+ Here is the caller graph for this function:

◆ marginsRemoved()

constexpr QRect QRect::marginsRemoved ( const QMargins & margins) const
inlineconstexprnoexcept

Removes the margins from the rectangle, shrinking it.

See also
marginsAdded(), operator+=(), operator-=()
Since
5.1

Definition at line 453 of file qrect.h.

Referenced by QLineEditPrivate::adjustedContentsRect(), QWindows11Style::drawControl(), QWindows11Style::drawPrimitive(), QWindowsBaseWindow::geometry_sys(), QtWaylandClient::QWaylandWindow::handleMouse(), QtWaylandClient::QWaylandBradientDecoration::paint(), and QWindowsWindow::setCustomMargins().

+ Here is the caller graph for this function:

◆ moveBottom()

constexpr void QRect::moveBottom ( int y)
inlineconstexprnoexcept

Moves the rectangle vertically, leaving the rectangle's bottom edge at the given y coordinate.

The rectangle's size is unchanged.

See also
bottom(), setBottom(), moveTop()

Definition at line 297 of file qrect.h.

References pos.

Referenced by QDockAreaLayout::constrainedRect(), and QListViewPrivate::scrollElasticBandBy().

+ Here is the caller graph for this function:

◆ moveBottomLeft()

constexpr void QRect::moveBottomLeft ( const QPoint & position)
inlineconstexprnoexcept

Moves the rectangle, leaving the bottom-left corner at the given position.

The rectangle's size is unchanged.

See also
setBottomLeft(), moveBottom(), moveLeft()

Definition at line 321 of file qrect.h.

◆ moveBottomRight()

constexpr void QRect::moveBottomRight ( const QPoint & position)
inlineconstexprnoexcept

Moves the rectangle, leaving the bottom-right corner at the given position.

The rectangle's size is unchanged.

See also
setBottomRight(), moveRight(), moveBottom()

Definition at line 309 of file qrect.h.

◆ moveCenter()

constexpr void QRect::moveCenter ( const QPoint & position)
inlineconstexprnoexcept

Moves the rectangle, leaving the center point at the given position.

The rectangle's size is unchanged.

See also
center()

Definition at line 327 of file qrect.h.

Referenced by QPagePreview::paintEvent().

+ Here is the caller graph for this function:

◆ moveLeft()

constexpr void QRect::moveLeft ( int x)
inlineconstexprnoexcept

Moves the rectangle horizontally, leaving the rectangle's left edge at the given x coordinate.

The rectangle's size is unchanged.

See also
left(), setLeft(), moveRight()

Definition at line 285 of file qrect.h.

References pos.

Referenced by QDockAreaLayout::constrainedRect(), QTabWidget::paintEvent(), and QListViewPrivate::scrollElasticBandBy().

+ Here is the caller graph for this function:

◆ moveRight()

constexpr void QRect::moveRight ( int x)
inlineconstexprnoexcept

Moves the rectangle horizontally, leaving the rectangle's right edge at the given x coordinate.

The rectangle's size is unchanged.

See also
right(), setRight(), moveLeft()

Definition at line 291 of file qrect.h.

References pos.

Referenced by QDockAreaLayout::constrainedRect(), and QListViewPrivate::scrollElasticBandBy().

+ Here is the caller graph for this function:

◆ moveTo() [1/2]

constexpr void QRect::moveTo ( const QPoint & p)
inlineconstexprnoexcept

Moves the rectangle, leaving the top-left corner at the given position.

Definition at line 277 of file qrect.h.

◆ moveTo() [2/2]

constexpr void QRect::moveTo ( int x,
int y )
inlineconstexprnoexcept

Moves the rectangle, leaving the top-left corner at the given position (x, y).

The rectangle's size is unchanged.

See also
translate(), moveTopLeft()

Definition at line 269 of file qrect.h.

Referenced by QQuickContext2DImageTexture::compositeTile(), QQC2_NAMESPACE::QMacStyle::drawControl(), QMacStyle::drawControl(), grayscale(), QWindowsWindow::setCustomMargins(), QGraphicsWidgetPrivate::windowFrameHoverMoveEvent(), and QGraphicsWidgetPrivate::windowFrameMouseReleaseEvent().

+ Here is the caller graph for this function:

◆ moveTop()

constexpr void QRect::moveTop ( int y)
inlineconstexprnoexcept

Moves the rectangle vertically, leaving the rectangle's top edge at the given y coordinate.

The rectangle's size is unchanged.

See also
top(), setTop(), moveBottom()

Definition at line 288 of file qrect.h.

References pos.

Referenced by QPrintPreviewWidgetPrivate::_q_fit(), QDockAreaLayout::constrainedRect(), QWindowsVistaStyle::drawControl(), QPixmapStyle::eventFilter(), QTabWidget::paintEvent(), QListViewPrivate::scrollElasticBandBy(), and QMenuPrivate::scrollMenu().

+ Here is the caller graph for this function:

◆ moveTopLeft()

constexpr void QRect::moveTopLeft ( const QPoint & position)
inlineconstexprnoexcept

Moves the rectangle, leaving the top-left corner at the given position.

The rectangle's size is unchanged.

See also
setTopLeft(), moveTop(), moveLeft()

Definition at line 303 of file qrect.h.

Referenced by QTabWidget::initStyleOption(), moveToVirtualScreen(), QtWaylandClient::QWaylandScreen::output_geometry(), QMainWindowLayout::plug(), QToolBarPrivate::unplug(), QDockWidgetPrivate::unplug(), and QtWaylandClient::QWaylandScreen::zxdg_output_v1_logical_position().

+ Here is the caller graph for this function:

◆ moveTopRight()

constexpr void QRect::moveTopRight ( const QPoint & position)
inlineconstexprnoexcept

Moves the rectangle, leaving the top-right corner at the given position.

The rectangle's size is unchanged.

See also
setTopRight(), moveTop(), moveRight()

Definition at line 315 of file qrect.h.

◆ normalized()

QRect QRect::normalized ( ) const
noexcept

Returns a normalized rectangle; i.e., a rectangle that has a non-negative width and height.

If width() < 0 the function swaps the left and right corners, and it swaps the top and bottom corners if height() < 0. The corners are at the same time changed from being non-inclusive to inclusive.

See also
isValid(), isEmpty()

Definition at line 273 of file qrect.cpp.

Referenced by QRasterPaintEngine::drawRects(), QWindowsDirect2DPaintEngine::drawRects(), QRasterPaintEnginePrivate::isUnclipped(), QSGSoftwarePixmapRenderer::render(), QQuickTableViewPrivate::updateSelection(), and QQuickTreeViewPrivate::updateSelection().

+ Here is the caller graph for this function:

◆ operator&()

QRect QRect::operator& ( const QRect & rectangle) const
noexcept

Returns the intersection of this rectangle and the given rectangle.

Returns an empty rectangle if there is no intersection.

See also
operator&=(), intersected()

Definition at line 993 of file qrect.cpp.

References qMax(), qMin(), r1, r2, and t2.

+ Here is the call graph for this function:

◆ operator&=()

QRect & QRect::operator&= ( const QRect & rectangle)
inlinenoexcept

Intersects this rectangle with the given rectangle.

See also
intersected(), operator&()

Definition at line 408 of file qrect.h.

◆ operator+=()

constexpr QRect & QRect::operator+= ( const QMargins & margins)
inlineconstexprnoexcept

Adds the margins to the rectangle, growing it.

See also
marginsAdded(), marginsRemoved(), operator-=()
Since
5.1

Definition at line 459 of file qrect.h.

◆ operator-=()

constexpr QRect & QRect::operator-= ( const QMargins & margins)
inlineconstexprnoexcept

Returns a rectangle shrunk by the margins.

See also
marginsRemoved(), operator+=(), marginsAdded()
Since
5.1

Definition at line 465 of file qrect.h.

◆ operator|()

QRect QRect::operator| ( const QRect & rectangle) const
noexcept

Returns the bounding rectangle of this rectangle and the given rectangle.

See also
operator|=(), united()

Definition at line 929 of file qrect.cpp.

References qMax(), qMin(), r1, r2, and t2.

+ Here is the call graph for this function:

◆ operator|=()

QRect & QRect::operator|= ( const QRect & rectangle)
inlinenoexcept

Unites this rectangle with the given rectangle.

See also
united(), operator|()

Definition at line 402 of file qrect.h.

◆ right()

constexpr int QRect::right ( ) const
inlineconstexprnoexcept

Returns the x-coordinate of the rectangle's right edge.

Note that for historical reasons this function returns left() + width() - 1; use x() + width() to retrieve the true x-coordinate.

See also
setRight(), topRight(), bottomRight()

Definition at line 178 of file qrect.h.

Referenced by QSpanBuffer::addSpan(), QWaylandXdgPositionerData::anchorPoint(), QDockAreaLayoutInfo::apply(), QToolBarAreaLayout::apply(), QWindowGeometrySpecification::applyTo(), QGroupBoxPrivate::calculateFrame(), QWidgetPrivate::checkRestoredGeometry(), clipStraightLine(), QDockAreaLayout::constrainedRect(), QWaylandQtShellChromePrivate::constrainPoint(), QToolBarAreaLayoutInfo::distance(), QGridLayoutPrivate::distribute(), QLabelPrivate::documentRect(), QAndroidStyle::Android9PatchDrawable::draw(), QQC2_NAMESPACE::QMacStyle::drawControl(), QQC2::QCommonStyle::drawControl(), QQC2::QWindowsStyle::drawControl(), QMacStyle::drawControl(), QCommonStyle::drawControl(), QQC2_NAMESPACE::QMacStyle::drawPrimitive(), QQC2::QCommonStyle::drawPrimitive(), QMacStyle::drawPrimitive(), QCommonStyle::drawPrimitive(), QMacStylePrivate::drawToolbarButtonArrow(), QPlainTextEditPrivate::ensureCursorVisible(), QRasterPaintEngine::fillPath(), QToolBarAreaLayoutInfo::fitLayout(), QWidget::frameGeometry(), QWidget::frameSize(), QDockAreaLayout::gapRect(), QDockAreaLayout::getGrid(), QIntersectionFinder::hasIntersections(), if(), QRasterPaintEnginePrivate::isUnclipped(), QRasterPaintEnginePrivate::isUnclipped_normalized(), QWidgetResizeHandler::keyPressEvent(), QTabBarPrivate::makeVisible(), QWidgetResizeHandler::mouseMoveEvent(), QComboBoxPrivateScroller::mouseMoveEvent(), QSizeGrip::mousePressEvent(), QAbstractButtonPrivate::moveFocus(), operator<<(), QtWaylandClient::QWaylandBradientDecoration::paint(), QTabBar::paintEvent(), QMenuBarPrivate::popupAction(), QDateTimeEditPrivate::positionCalendarPopup(), QQC2::qDrawBorderPixmap(), QSGSoftwareHelpers::qDrawBorderPixmap(), qRectIntersects(), qt_intersect_spans(), QRasterizer::rasterize(), QRasterizer::rasterize(), QRasterizer::rasterizeLine(), read_jpeg_image(), QMdi::RegularTiler::rearrange(), rect_intersects(), QPdfDocument::render(), QAndroidPlatformWindow::safeAreaMargins(), QListViewPrivate::scrollElasticBandBy(), QFrame::setFrameRect(), QDockWidgetLayout::setGeometry(), QDockAreaLayout::setGrid(), QWidgetPrivate::setLayoutItemMargins(), QMenu::sizeHint(), QPlainTextEdit::timerEvent(), QTextEdit::timerEvent(), QWaylandQtShellChromePrivate::updateDecorationInteraction(), QMenuBarPrivate::updateGeometries(), QTableView::updateGeometries(), QMdiAreaPrivate::updateScrollBars(), QAndroidInputContext::updateSelectionHandles(), QFramePrivate::updateStyledFrameWidths(), and useScrollBar().

◆ setBottom()

constexpr void QRect::setBottom ( int y)
inlineconstexprnoexcept

Sets the bottom edge of the rectangle to the given y coordinate.

May change the height, but will never change the top edge of the rectangle.

See also
bottom(), moveBottom(),

Definition at line 199 of file qrect.h.

References pos.

Referenced by QLabelPrivate::documentRect(), QPixmapStyle::drawPanelItemViewItem(), QWindowsVistaStyle::drawPrimitive(), QPixmapStyle::drawProgressBarFill(), QToolBarAreaLayoutInfo::fitLayout(), QBspTree::init(), QDockWidgetPrivate::nonClientAreaMouseEvent(), QMenuPrivate::scrollMenu(), and QListView::setSelection().

+ Here is the caller graph for this function:

◆ setBottomLeft()

constexpr void QRect::setBottomLeft ( const QPoint & position)
inlineconstexprnoexcept

Set the bottom-left corner of the rectangle to the given position.

May change the size, but will never change the top-right corner of the rectangle.

See also
bottomLeft(), moveBottomLeft()

Definition at line 211 of file qrect.h.

◆ setBottomRight()

constexpr void QRect::setBottomRight ( const QPoint & position)
inlineconstexprnoexcept

Set the bottom-right corner of the rectangle to the given position.

May change the size, but will never change the top-left corner of the rectangle.

See also
bottomRight(), moveBottomRight()

Definition at line 205 of file qrect.h.

◆ setCoords()

constexpr void QRect::setCoords ( int x1,
int y1,
int x2,
int y2 )
inlineconstexprnoexcept

Sets the coordinates of the rectangle's top-left corner to (x1, y1), and the coordinates of its bottom-right corner to (x2, y2).

See also
getCoords(), setRect()

Definition at line 361 of file qrect.h.

Referenced by _q_interpolate(), QQC2::QCommonStyle::drawControl(), QCommonStyle::drawControl(), QWindowsVistaStylePrivate::region(), and QQC2::QWindowsXPStylePrivate::region().

+ Here is the caller graph for this function:

◆ setHeight()

constexpr void QRect::setHeight ( int height)
inlineconstexprnoexcept

◆ setLeft()

constexpr void QRect::setLeft ( int x)
inlineconstexprnoexcept

◆ setRect()

constexpr void QRect::setRect ( int x,
int y,
int width,
int height )
inlineconstexprnoexcept

Sets the coordinates of the rectangle's top-left corner to ({x}, {y}), and its size to the given width and height.

See also
getRect(), setCoords()

Definition at line 345 of file qrect.h.

Referenced by QtPrivate::QWellArray::cellGeometry(), QItemDelegate::doLayout(), QQC2::QCommonStyle::drawComplexControl(), QCommonStyle::drawComplexControl(), QQC2::QCommonStyle::drawControl(), QCommonStyle::drawControl(), QTreeView::drawRow(), QClipData::fixup(), QTabBarPrivate::initStyleBaseOption(), QHeaderView::mouseReleaseEvent(), QMenu::paintEvent(), QGraphicsView::render(), QHeaderView::resizeSection(), QQC2_NAMESPACE::rotateTabPainter(), and QWindowsVistaStyle::subElementRect().

+ Here is the caller graph for this function:

◆ setRight()

constexpr void QRect::setRight ( int x)
inlineconstexprnoexcept

Sets the right edge of the rectangle to the given x coordinate.

May change the width, but will never change the left edge of the rectangle.

See also
right(), moveRight()

Definition at line 196 of file qrect.h.

References pos.

Referenced by QLabelPrivate::documentRect(), QQC2::QCommonStyle::drawControl(), QCommonStyle::drawControl(), QWindows11Style::drawControl(), QToolBarAreaLayoutInfo::fitLayout(), if(), QBspTree::init(), QDockWidgetPrivate::nonClientAreaMouseEvent(), QtWaylandClient::QWaylandAdwaitaDecoration::paint(), QtWaylandClient::QWaylandBradientDecoration::paint(), and QListView::setSelection().

+ Here is the caller graph for this function:

◆ setSize()

◆ setTop()

constexpr void QRect::setTop ( int y)
inlineconstexprnoexcept

Sets the top edge of the rectangle to the given y coordinate.

May change the height, but will never change the bottom edge of the rectangle.

Equivalent to setY().

See also
top(), moveTop()

Definition at line 193 of file qrect.h.

References pos.

Referenced by QToolBarAreaLayout::apply(), QLabelPrivate::documentRect(), QLayoutPrivate::doResize(), QWindowsVistaStyle::drawPrimitive(), QToolBarAreaLayoutInfo::fitLayout(), QBspTree::init(), QMenu::paintEvent(), QMenuPrivate::scrollMenu(), QDockAreaLayout::setGrid(), QListView::setSelection(), QQC2::QCommonStyle::subControlRect(), and QCommonStyle::subControlRect().

+ Here is the caller graph for this function:

◆ setTopLeft()

constexpr void QRect::setTopLeft ( const QPoint & position)
inlineconstexprnoexcept

Set the top-left corner of the rectangle to the given position.

May change the size, but will never change the bottom-right corner of the rectangle.

See also
topLeft(), moveTopLeft()

Definition at line 202 of file qrect.h.

Referenced by QMdiSubWindowPrivate::setNewGeometry().

+ Here is the caller graph for this function:

◆ setTopRight()

constexpr void QRect::setTopRight ( const QPoint & position)
inlineconstexprnoexcept

Set the top-right corner of the rectangle to the given position.

May change the size, but will never change the bottom-left corner of the rectangle.

See also
topRight(), moveTopRight()

Definition at line 208 of file qrect.h.

◆ setWidth()

constexpr void QRect::setWidth ( int width)
inlineconstexprnoexcept

Sets the width of the rectangle to the given width.

The right edge is changed, but not the left one.

See also
width(), setSize()

Definition at line 380 of file qrect.h.

Referenced by QWidgetPrivate::adjustedSize(), QDockAreaLayout::constrainedRect(), QWindowsVistaStyle::drawControl(), QOffscreenBackingStore::grabWindow(), QmlJSDebugger::SelectionHighlight::paint(), QComboBoxDelegate::paint(), QMdiAreaPrivate::resizeToMinimumTileSize(), QDockAreaLayout::setGrid(), QAndroidStyle::sizeFromContents(), QAndroidStyle::subControlRect(), and QMenuPrivate::updateActionRects().

+ Here is the caller graph for this function:

◆ setX()

constexpr void QRect::setX ( int x)
inlineconstexprnoexcept

Sets the left edge of the rectangle to the given x coordinate.

May change the width, but will never change the right edge of the rectangle.

Equivalent to setLeft().

See also
x(), setY(), setTopLeft()

Definition at line 214 of file qrect.h.

Referenced by QRasterPaintEnginePrivate::isUnclipped(), QDateTimeEditPrivate::positionCalendarPopup(), QQuick3DParticleShapeDataUtils::readValue(), QWasmBackingStore::updateTexture(), and QTreeView::visualRegionForSelection().

+ Here is the caller graph for this function:

◆ setY()

constexpr void QRect::setY ( int y)
inlineconstexprnoexcept

Sets the top edge of the rectangle to the given y coordinate.

May change the height, but will never change the bottom edge of the rectangle.

Equivalent to setTop().

See also
y(), setX(), setTopLeft()

Definition at line 217 of file qrect.h.

◆ size()

constexpr QSize QRect::size ( ) const
inlineconstexprnoexcept

Returns the size of the rectangle.

See also
setSize(), width(), height()

Definition at line 241 of file qrect.h.

Referenced by QQnxEglWindow::QQnxEglWindow(), QMoviePrivate::_q_loadNextFrame(), _q_paintIntoCache(), QWidgetPrivate::adjustedSize(), QStyle::alignedRect(), QQC2::QStyle::alignedRect(), QtWaylandClient::QWaylandWlShellSurface::applyConfigure(), QWindowGeometrySpecification::applyTo(), QScreen::availableVirtualSize(), QQuickContext2DImageTexture::beginPainting(), QQuickContext2DTexture::canvasChanged(), QItemDelegate::doLayout(), QQC2_NAMESPACE::QMacStyle::drawControl(), QMacStyle::drawControl(), QGraphicsScenePrivate::drawItemHelper(), QWindowsVistaStyle::drawPrimitive(), QDockAreaLayoutInfo::fitItems(), QToolBarAreaLayoutLine::fitLayout(), QWindowsDirect2DWindow::flush(), QtWaylandClient::QWaylandScreen::geometry(), QDockAreaLayout::getGrid(), QOpenGLCompositor::grab(), QOpenGLCompositor::grabToFrameBufferObject(), QEglFSScreen::grabWindow(), QWindowsScreen::grabWindow(), QXcbScreen::grabWindow(), QWindowsWindow::handleDpiChanged(), QWindowsWindow::handleDpiScaledSize(), QBsdFbScreen::initialize(), QLinuxFbScreen::initialize(), QFbScreen::initializeCompositor(), QEglFSKmsVsp2Screen::initQtLayer(), QDockAreaLayoutInfo::insertGap(), QWaylandXdgPositionerData::isComplete(), QDockAreaLayoutInfo::itemRect(), QQuickIconLabelPrivate::layout(), QTabBar::minimumSizeHint(), QWidgetResizeHandler::mouseMoveEvent(), QToolBarAreaLayoutInfo::moveToolBar(), QPdfEnginePrivate::newPage(), QFont::operator<(), QtWaylandClient::QWaylandScreen::output_mode(), QPagePreview::paintEvent(), QLabel::paintEvent(), QEglFSKmsScreen::physicalSize(), QPrintPreviewWidgetPrivate::populateScene(), QGuiApplicationPrivate::processGeometryChangeEvent(), QEglFSEmulatorScreen::rawGeometry(), QSvgIOHandler::read(), QPdfIOHandler::read(), read_jpeg_image(), QWidgetPrivate::render_helper(), QWidget::restoreGeometry(), QMainWindowLayoutState::restoreState(), QDockAreaLayout::saveState(), QDockAreaLayoutInfo::separatorRect(), QAndroidPlatformScreen::setAvailableGeometry(), QWasmWindow::setGeometry(), QFbScreen::setGeometry(), QQnxEglWindow::setGeometry(), QQnxWindow::setGeometry(), QMdiSubWindowPrivate::setNewGeometry(), QMdiSubWindowPrivate::setNewGeometry(), QQnxScreen::setRotation(), QDockAreaLayoutInfo::size(), QFontMetrics::size(), QQC2::QCommonStyle::sizeFromContents(), QAndroidStyle::sizeFromContents(), QTabBar::sizeHint(), QTabWidget::sizeHint(), QComboMenuDelegate::sizeHint(), QMacStyle::styleHint(), QQC2_NAMESPACE::QMacStyle::styleHint(), QAndroidStyle::subControlRect(), QQuick3DSceneRenderer::synchronize(), QSGRhiAtlasTexture::Texture::textureSize(), QXcbScreen::updateGeometry(), QQuickTextPrivate::updateSize(), QWasmVideoOutput::updateVideoElementGeometry(), QScreen::virtualSize(), and QtWaylandClient::QWaylandQtSurface::zqt_shell_surface_v1_set_frame_margins().

◆ span()

constexpr QRect QRect::span ( const QPoint & p1,
const QPoint & p2 )
inlinestaticconstexprnoexcept

Returns a rectangle spanning the two points p1 and p2, including both and everything in between.

Since
6.0

Definition at line 471 of file qrect.h.

References p1, p2, qMax(), and qMin().

Referenced by qt_mapFillRect().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ top()

constexpr int QRect::top ( ) const
inlineconstexprnoexcept

Returns the y-coordinate of the rectangle's top edge.

Equivalent to y().

See also
setTop(), topLeft(), topRight()

Definition at line 175 of file qrect.h.

Referenced by QSpanBuffer::addSpan(), QWaylandXdgPositionerData::anchorPoint(), QDockAreaLayoutInfo::apply(), QWindowGeometrySpecification::applyTo(), QOpenGLFramebufferObject::blitFramebuffer(), QCommonStylePrivate::calculateElidedText(), QQC2::QCommonStylePrivate::calculateElidedText(), QGroupBoxPrivate::calculateFrame(), QWidgetPrivate::checkRestoredGeometry(), clipStraightLine(), QDockAreaLayout::constrainedRect(), QWaylandQtShellChromePrivate::constrainPoint(), QQuickContext2DTile::createPainter(), QToolBarAreaLayoutInfo::distance(), QLabelPrivate::documentRect(), QLayoutPrivate::doResize(), QAndroidStyle::Android9PatchDrawable::draw(), QQC2_NAMESPACE::QMacStyle::drawControl(), QQC2::QCommonStyle::drawControl(), QQC2::QWindowsStyle::drawControl(), QMacStyle::drawControl(), QCommonStyle::drawControl(), QGraphicsScenePrivate::drawItemHelper(), QWindowsVistaStyle::drawPrimitive(), QQC2_NAMESPACE::QMacStyle::drawPrimitive(), QMacStyle::drawPrimitive(), QPlainTextEditPrivate::ensureCursorVisible(), QPixmapStyle::eventFilter(), QRasterPaintEngine::fillPath(), QDockAreaLayout::fitLayout(), QToolBarAreaLayoutInfo::fitLayout(), QToolBarAreaLayout::fitLayout(), QWidget::frameGeometry(), QWidget::frameSize(), QDockAreaLayout::gapRect(), QDockAreaLayout::getGrid(), QIntersectionFinder::hasIntersections(), QRasterPaintEnginePrivate::isUnclipped(), QRasterPaintEnginePrivate::isUnclipped_normalized(), QWidgetResizeHandler::keyPressEvent(), QTabBarPrivate::makeVisible(), QWidgetResizeHandler::mouseMoveEvent(), QListView::moveCursor(), QToolBarAreaLayoutInfo::moveToolBar(), QtWaylandClient::QWaylandBradientDecoration::paint(), QTabBar::paintEvent(), QMenuBarPrivate::popupAction(), QDateTimeEditPrivate::positionCalendarPopup(), QQC2::qDrawBorderPixmap(), QSGSoftwareHelpers::qDrawBorderPixmap(), qRectIntersects(), qt_intersect_spans(), qt_scrollRectInImage(), qt_transform_image_rasterize(), QRasterizer::rasterize(), QRasterizer::rasterize(), QRasterizer::rasterizeLine(), rect_intersects(), QPdfDocument::render(), QGraphicsView::render(), QAndroidPlatformWindow::safeAreaMargins(), QListViewPrivate::scrollElasticBandBy(), QMenuPrivate::scrollMenu(), setDisplayMetrics(), QFrame::setFrameRect(), QDockAreaLayout::setGrid(), QWidgetPrivate::setLayoutItemMargins(), QLinuxMediaDevice::setSubdevSelection(), QBoxLayoutPrivate::setupGeom(), spacingHelper(), QQC2::QCommonStyle::subElementRect(), QCommonStyle::subElementRect(), QPlainTextEdit::timerEvent(), QTextEdit::timerEvent(), QWaylandQtShellChromePrivate::updateDecorationInteraction(), QTableView::updateGeometries(), QTreeView::updateGeometries(), QMdiAreaPrivate::updateScrollBars(), QFramePrivate::updateStyledFrameWidths(), QWasmVideoOutput::updateVideoElementGeometry(), useScrollBar(), QCommonListViewBase::verticalScrollToValue(), and QTreeView::visualRegionForSelection().

◆ topLeft()

constexpr QPoint QRect::topLeft ( ) const
inlineconstexprnoexcept

Returns the position of the rectangle's top-left corner.

See also
setTopLeft(), top(), left()

Definition at line 220 of file qrect.h.

Referenced by _q_paintIntoCache(), QQuickTextNodeEngine::addTextBlock(), QWindowGeometrySpecification::applyTo(), QGraphicsItem::boundingRegion(), QFbCursor::changeCursor(), QWidgetPrivate::clipToEffectiveMask(), QQuickContext2DImageTexture::compositeTile(), QDockAreaLayout::constrainedRect(), QFbScreen::doRedraw(), QQC2_NAMESPACE::QMacStyle::drawControl(), QMacStyle::drawControl(), QFbCursor::drawCursor(), QItemDelegate::drawDisplay(), QGraphicsScenePrivate::drawItemHelper(), QTextDocumentLayoutPrivate::drawListItem(), QWindowsVistaStyle::drawPrimitive(), QQC2_NAMESPACE::QMacStyle::drawPrimitive(), QQC2::QCommonStyle::drawPrimitive(), QQC2::QWindowsStyle::drawPrimitive(), QMacStyle::drawPrimitive(), QCommonStyle::drawPrimitive(), QDockWidget::event(), QDockAreaLayoutInfo::fitItems(), QBackingStore::flush(), QToolBarAreaLayoutInfo::gapIndex(), QtWaylandClient::QWaylandScreen::geometry(), QWidget::grab(), QBsdFbScreen::grabWindow(), QEglFSScreen::grabWindow(), QIntegrityFbScreen::grabWindow(), QLinuxFbScreen::grabWindow(), QVncScreen::grabWindow(), QWindowSystemInterface::handleScreenGeometryChange(), QTabWidget::initStyleOption(), QDockAreaLayoutInfo::itemRect(), QQuickIconLabelPrivate::layout(), QWasmScreen::mapFromLocal(), QtPrivate::QColorPicker::mouseMoveEvent(), QWidgetResizeHandler::mouseMoveEvent(), QtPrivate::QColorPicker::mousePressEvent(), moveToVirtualScreen(), QWidgetPrivate::overlappedRegion(), QtPrivate::PageItem::paint(), QHeaderView::paintSection(), QFbCursor::pointerEvent(), QGuiApplicationPrivate::processGeometryChangeEvent(), QXcbBackingStoreImage::put(), QRasterizer::rasterizeLine(), QSvgIOHandler::read(), QPdfIOHandler::read(), read_jpeg_image(), QXcbSystemTrayBackingStore::render(), QWidgetPrivate::render_helper(), QSGRhiDistanceFieldGlyphCache::requestGlyphs(), QWidget::restoreGeometry(), QMainWindowLayoutState::restoreState(), QPlatformWindow::screenForGeometry(), QQC2::QWindowsXPStylePrivate::scrollBarGripperBounds(), QDockAreaLayoutInfo::separatorRect(), QWaylandOutput::setAvailableGeometry(), QFbScreen::setDirty(), QMdiSubWindowPrivate::setNewGeometry(), QFbCursor::setPos(), showSystemMenu(), QWidgetPrivate::subtractOpaqueSiblings(), QQuick3DSceneRenderer::synchronize(), QScreenPrivate::updateGeometry(), QPaintEnginePrivate::updateSystemClip(), QWasmVideoOutput::updateVideoElementGeometry(), QQuickScreenInfo::virtualX(), QQuickScreenInfo::virtualY(), windowPlacementOffset(), and QtWaylandClient::QWaylandQtSurface::zqt_shell_surface_v1_set_frame_margins().

◆ topRight()

constexpr QPoint QRect::topRight ( ) const
inlineconstexprnoexcept

Returns the position of the rectangle's top-right corner.

Note that for historical reasons this function returns QPoint(left() + width() -1, top()).

See also
setTopRight(), top(), right()

Definition at line 226 of file qrect.h.

Referenced by QQC2_NAMESPACE::QMacStyle::drawControl(), QQC2::QWindowsStyle::drawControl(), QMacStyle::drawControl(), QQC2::QWindowsXPStyle::drawControl(), QWindows11Style::drawControl(), QWindowsVistaStyle::drawControl(), QQC2_NAMESPACE::QMacStyle::drawPrimitive(), and QMacStyle::drawPrimitive().

+ Here is the caller graph for this function:

◆ toRectF()

constexpr QRectF QRect::toRectF ( ) const
inlineconstexprnoexcept
Since
6.4

Returns this rectangle as a rectangle with floating point accuracy.

Note
This function, like the QRectF(QRect) constructor, preserves the size() of the rectangle, not its bottomRight() corner.
See also
QRectF::toRect()

Definition at line 843 of file qrect.h.

Referenced by QWasmScreen::clipPoint(), and QSvgMask::createMask().

+ Here is the caller graph for this function:

◆ translate() [1/2]

constexpr void QRect::translate ( const QPoint & offset)
inlineconstexprnoexcept

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Moves the rectangle {offset}.

\l{QPoint::x()}{x()} along the x axis and {offset}.\l{QPoint::y()}{y()} along the y axis, relative to the current position.

Definition at line 252 of file qrect.h.

◆ translate() [2/2]

◆ translated() [1/2]

constexpr QRect QRect::translated ( const QPoint & offset) const
inlineconstexprnoexcept

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Returns a copy of the rectangle that is translated {offset}.

\l{QPoint::x()}{x()} along the x axis and {offset}.\l{QPoint::y()}{y()} along the y axis, relative to the current position.

Definition at line 263 of file qrect.h.

◆ translated() [2/2]

constexpr QRect QRect::translated ( int dx,
int dy ) const
inlineconstexprnoexcept

Returns a copy of the rectangle that is translated dx along the x axis and dy along the y axis, relative to the current position.

Positive values move the rectangle to the right and down.

See also
translate()

Definition at line 260 of file qrect.h.

Referenced by QSvgFeOffset::apply(), QSvgFilterContainer::applyFilter(), QGraphicsItem::boundingRegion(), QFbCursor::changeCursor(), clippedBlit(), QFbScreen::doRedraw(), QListViewPrivate::draggablePaintPairs(), QFbCursor::drawCursor(), QRasterPaintEngine::drawImage(), QRasterPaintEngine::drawRects(), QOffscreenBackingStore::flush(), QWindowsBackingStore::flush(), QXcbNativeBackingStore::flush(), QXcbBackingStore::flush(), QOffscreenBackingStore::grabWindow(), QWidgetPrivate::mapFromWS(), QMatrix4x4::mapRect(), QDoubleMatrix4x4::mapRect(), QWidgetPrivate::mapToWS(), QWidgetRepaintManager::markDirty(), QAbstractButtonPrivate::moveFocus(), QWidgetPrivate::moveRect(), QQuickLabsPlatformMenu::open(), QListView::paintEvent(), QFbCursor::pointerEvent(), prepareDrawForRenderToTextureWidget(), QXcbBackingStoreImage::put(), qt_scrollRectInImage(), QXcbSystemTrayBackingStore::render(), QXcbBackingStoreImage::scroll(), QWidget::scroll(), QPixmap::scroll(), QGraphicsItem::scroll(), QWidgetPrivate::scrollRect(), QTabBarPrivate::scrollTabs(), QFbScreen::setDirty(), QFbCursor::setPos(), QWidgetPrivate::subtractOpaqueSiblings(), QtWaylandClient::QWaylandTextInputv1::updateState(), QtWaylandClient::QWaylandTextInputv2::updateState(), and QtWaylandClient::QWaylandTextInputv3::updateState().

+ Here is the caller graph for this function:

◆ transposed()

constexpr QRect QRect::transposed ( ) const
inlineconstexprnoexcept
Since
5.7

Returns a copy of the rectangle that has its width and height exchanged:

QRect r = {15, 51, 42, 24};
r = r.transposed(); // r == {15, 51, 24, 42}
See also
QSize::transposed()

Definition at line 266 of file qrect.h.

Referenced by QQC2_NAMESPACE::QMacStyle::drawControl(), QQC2::QWindowsStyle::drawControl(), and QMacStyle::drawControl().

+ Here is the caller graph for this function:

◆ united()

QRect QRect::united ( const QRect & rectangle) const
inlinenoexcept
Since
4.2

Returns the bounding rectangle of this rectangle and the given rectangle.

See also
intersected()

Definition at line 419 of file qrect.h.

Referenced by QSvgFeComposite::apply(), QQC2::QCommonStyle::drawComplexControl(), QCommonStyle::drawComplexControl(), QAndroidStyle::drawComplexControl(), QQC2::QWindowsXPStyle::drawComplexControl(), QWindowsVistaStyle::drawComplexControl(), QTabBar::minimumSizeHint(), QListView::mouseMoveEvent(), QMenu::paintEvent(), QAndroidStyle::sizeFromContents(), QTabBar::sizeHint(), QWindowsVistaStyle::subElementRect(), and src_gui_painting_qregion_unix::wrapper().

+ Here is the caller graph for this function:

◆ width()

constexpr int QRect::width ( ) const
inlineconstexprnoexcept

Returns the width of the rectangle.

See also
setWidth(), height(), size()

Definition at line 235 of file qrect.h.

Referenced by QVncDirtyMap::QVncDirtyMap(), QWhatsThat::QWhatsThat(), QWindowCreationContext::QWindowCreationContext(), QQuickTextNodeEngine::addTextBlock(), QWaylandXdgPositionerData::anchorPoint(), QDockAreaLayoutInfo::apply(), QFormLayoutPrivate::arrangeWidgets(), QQnxScreen::availableGeometry(), QXcbVirtualDesktop::availableGeometry(), QPainter::begin(), QOpenGLFramebufferObject::blitFramebuffer(), QGraphicsItem::boundingRegion(), QPrintPreviewWidgetPrivate::calcCurrentPage(), QCommonStylePrivate::calculateElidedText(), QQC2::QCommonStylePrivate::calculateElidedText(), QAndroidPlatformOpenGLWindow::checkNativeSurface(), QWidgetPrivate::checkRestoredGeometry(), QSplitterHandle::closestLegalPosition(), QWaylandQtShellSurfacePrivate::configure(), QDockAreaLayout::constrainedRect(), QPathClipper::contains(), correctMVPForScissor(), QQuickContext2DTile::createPainter(), QItemDelegate::doLayout(), QLayoutPrivate::doResize(), QAndroidStyle::Android9PatchDrawable::draw(), QAndroidStyle::AndroidGradientDrawable::draw(), QWindowsVistaStylePrivate::drawBackgroundThruNativeBuffer(), QQC2::QWindowsXPStylePrivate::drawBackgroundThruNativeBuffer(), QWindows11Style::drawComplexControl(), QQC2_NAMESPACE::QMacStyle::drawControl(), QQC2::QCommonStyle::drawControl(), QQC2::QWindowsStyle::drawControl(), QMacStyle::drawControl(), QCommonStyle::drawControl(), QQC2::QWindowsXPStyle::drawControl(), QWindows11Style::drawControl(), QWindowsVistaStyle::drawControl(), QItemDelegate::drawDisplay(), dom::drawImageToWebImageDataArray(), QGraphicsScenePrivate::drawItemHelper(), QTextDocumentLayoutPrivate::drawListItem(), QQC2_NAMESPACE::QMacStyle::drawPrimitive(), QQC2::QCommonStyle::drawPrimitive(), QQC2::QWindowsStyle::drawPrimitive(), QAndroidStyle::drawPrimitive(), QMacStyle::drawPrimitive(), QCommonStyle::drawPrimitive(), QPaintEngine::drawRects(), QPainter::drawRects(), QTreeView::drawRow(), QQC2_NAMESPACE::drawTabBase(), QQC2_NAMESPACE::drawTabShape(), dumpNativeWindowsRecursion(), QOutlineMapper::endOutline(), QPlainTextEditPrivate::ensureCursorVisible(), QDockAreaLayout::fitLayout(), QToolBarAreaLayout::fitLayout(), QWindowsBackingStore::flush(), QXcbNativeBackingStore::flush(), QWindowsDirect2DWindow::flush(), QDockAreaLayout::gapRect(), QDockAreaLayout::getGrid(), QBsdFbScreen::grabWindow(), QEglFSScreen::grabWindow(), QIntegrityFbScreen::grabWindow(), QLinuxFbScreen::grabWindow(), QVncScreen::grabWindow(), QOffscreenBackingStore::grabWindow(), QOffscreenScreen::grabWindow(), QQnxScreen::grabWindow(), QTableViewPrivate::heightHintForIndex(), QClipData::initialize(), QBsdFbScreen::initialize(), QLinuxFbScreen::initialize(), QVncScreen::initialize(), QTabBar::initStyleOption(), QGraphicsWidgetPrivate::initStyleOptionTitleBar(), QSpanData::initTexture(), QColorDialogPrivate::initWidgets(), QPathClipper::intersect(), QQnxInputContext::keyboardRect(), QMdiSubWindow::keyPressEvent(), QPicture::metric(), QPaintDeviceWindow::metric(), QWidget::metric(), QOpenGLWidget::metric(), QMenuBar::minimumSizeHint(), QSizeGrip::mousePressEvent(), QTabBar::mouseReleaseEvent(), QQC2_NAMESPACE::QMacStyle::ninePatchMargins(), operator<<(), operator<<(), QIOSScreen::orientation(), QSGOpenVGPainterNode::paint(), QSGSoftwarePainterNode::paint(), QSGDefaultPainterNode::paint(), QSGSoftwareInternalRectangleNode::paint(), QmlJSDebugger::SelectionHighlight::paint(), QQuickUniversalFocusRectangle::paint(), QPagePreview::paintEvent(), QLabel::paintEvent(), QHeaderView::paintEvent(), QPlainTextEdit::paintEvent(), QScrollBarPrivate::pixelPosToRangeValue(), QSliderPrivate::pixelPosToRangeValue(), QTipLabel::placeTip(), QLineEditPrivate::positionSideWidgets(), QQuick3DSGRenderNode::prepare(), QWindowsDirect2DWindow::present(), qDrawRoundedCorners(), qNormalizeRadii(), QRectF_intersects(), qt_scrollRectInImage(), qt_transform_image_rasterize(), QRasterPaintEnginePrivate::rasterize(), read_jpeg_image(), QMdi::RegularTiler::rearrange(), QMdi::SimpleCascader::rearrange(), QMdi::IconTiler::rearrange(), QGraphicsView::render(), QProgressBarPrivate::repaintRequired(), QSGRhiDistanceFieldGlyphCache::requestGlyphs(), QWidget::resize(), QXcbNativeBackingStore::resize(), QMdiAreaPrivate::resizeToMinimumTileSize(), QQC2_NAMESPACE::rotateTabPainter(), QAlphaWidget::run(), QDockAreaLayoutInfo::saveState(), QWhatsThisPrivate::say(), QQC2::QWindowsXPStylePrivate::scrollBarGripperBounds(), QPixmapStyle::scrollBarSubControlRect(), QAndroidPlatformScreen::setAvailableGeometry(), QPolygonClipper< InType, OutType, CastType >::setBoundingRect(), QWindowsWindow::setCustomMargins(), setDisplayMetrics(), QBoxLayout::setGeometry(), QDockWidgetLayout::setGeometry(), QAndroidPlatformOpenGLWindow::setGeometry(), QAndroidPlatformVulkanWindow::setGeometry(), QFormLayout::setGeometry(), QMdiSubWindowPrivate::setMaximizeMode(), QMdiSubWindowPrivate::setNewGeometry(), QQnxScreen::setRotation(), QLinuxMediaDevice::setSubdevSelection(), QAndroidPlatformWindow::setVisible(), QtAndroidMenu::showContextMenu(), QLabelPrivate::sizeForWidth(), QMenu::sizeHint(), QMenuBar::sizeHint(), QMdiSubWindowPrivate::sizeParameters(), QQC2_NAMESPACE::QMacStyle::subControlRect(), QQC2::QCommonStyle::subControlRect(), QMacStyle::subControlRect(), QCommonStyle::subControlRect(), QWindows11Style::subControlRect(), QQC2_NAMESPACE::QMacStyle::subElementRect(), QQC2::QCommonStyle::subElementRect(), QMacStyle::subElementRect(), QCommonStyle::subElementRect(), QQC2::QMacStylePrivate::tabLayout(), QPlainTextEdit::timerEvent(), QTextEdit::timerEvent(), QQC2::QCommonStylePrivate::toolButtonElideText(), QtWaylandClient::QWaylandScreen::toScreenOrientation(), QX11PlatformPixmap::transformed(), glyph_metrics_t::transformed(), QWindowsMouseHandler::translateTouchEvent(), QSGSoftwareInternalRectangleNode::update(), QTableView::updateGeometries(), QTreeView::updateGeometries(), QWin32PrintEnginePrivate::updateMetrics(), QScreenPrivate::updatePrimaryOrientation(), QIOSScreen::updateProperties(), QGraphicsViewPrivate::updateRect(), QMdiAreaPrivate::updateScrollBars(), QQuickTreeViewPrivate::updateSelection(), QTipLabel::updateSize(), QWasmVideoOutput::updateVideoElementGeometry(), updateWindow(), and useScrollBar().

◆ x()

constexpr int QRect::x ( ) const
inlineconstexprnoexcept

Returns the x-coordinate of the rectangle's left edge.

Equivalent to left().

See also
setX(), y(), topLeft()

Definition at line 184 of file qrect.h.

Referenced by QWindowCreationContext::QWindowCreationContext(), QLineEditPrivate::adjustedControlRect(), QDialog::adjustPosition(), QStyle::alignedRect(), QQC2::QStyle::alignedRect(), QFormLayoutPrivate::arrangeWidgets(), QQnxScreen::availableGeometry(), QQnxRasterWindow::blitPreviousToCurrent(), QCommonStylePrivate::calculateElidedText(), QQC2::QCommonStylePrivate::calculateElidedText(), QWaylandQtShellSurfacePrivate::configure(), QPathClipper::contains(), QQuickContext2DTile::createPainter(), QAndroidStyle::AndroidImageDrawable::draw(), QWindowsVistaStylePrivate::drawBackgroundThruNativeBuffer(), QQC2::QWindowsXPStylePrivate::drawBackgroundThruNativeBuffer(), QQC2_NAMESPACE::QMacStyle::drawControl(), QQC2::QCommonStyle::drawControl(), QMacStyle::drawControl(), QCommonStyle::drawControl(), QWindows11Style::drawControl(), QWindowsVistaStyle::drawControl(), dom::drawImageToWebImageDataArray(), QGraphicsScenePrivate::drawItemHelper(), QQC2_NAMESPACE::QMacStyle::drawPrimitive(), QQC2::QCommonStyle::drawPrimitive(), QQC2::QWindowsStyle::drawPrimitive(), QAndroidStyle::drawPrimitive(), QMacStyle::drawPrimitive(), QCommonStyle::drawPrimitive(), QPaintEngine::drawRects(), QPaintEngineEx::drawRects(), dumpNativeWindowsRecursion(), QOutlineMapper::endOutline(), QDockWidget::event(), QAlphaWidget::eventFilter(), QBlitterPaintEngine::fillRect(), QWindowsBackingStore::flush(), QXcbNativeBackingStore::flush(), QColorDialogPrivate::grabScreenColor(), grabScreenColor(), QWindowsScreen::grabWindow(), QQnxScreen::grabWindow(), QXcbScreen::grabWindow(), QBsdFbScreen::initialize(), QLinuxFbScreen::initialize(), QSpanData::initTexture(), QLineEditPrivate::inSelection(), QPathClipper::intersect(), QWidgetPrivate::invalidateBackingStore_resizeHelper(), QQnxInputContext::keyboardRect(), QMdiSubWindow::keyPressEvent(), QWidgetResizeHandler::mouseMoveEvent(), QSizeGrip::mousePressEvent(), QAbstractButtonPrivate::moveFocus(), operator<<(), operator<<(), QSGOpenVGPainterNode::paint(), QSGSoftwarePainterNode::paint(), QSGDefaultPainterNode::paint(), QPagePreview::paintEvent(), QtPrivate::QWellArray::paintEvent(), QLabel::paintEvent(), QTabWidget::paintEvent(), QTipLabel::placeTip(), QMenuBarPrivate::popupAction(), QQnxRasterWindow::post(), QWindowsDirect2DWindow::present(), QRasterPaintEnginePrivate::rasterize(), read_jpeg_image(), QWidgetPrivate::render_helper(), QSGRhiDistanceFieldGlyphCache::requestGlyphs(), QXcbNativeBackingStore::resize(), QAlphaWidget::run(), QRollEffect::run(), QDockAreaLayoutInfo::saveState(), QWhatsThisPrivate::say(), QPolygonClipper< InType, OutType, CastType >::setBoundingRect(), QClipData::setClipRect(), QClipData::setClipRegion(), QWindowsWindow::setCustomMargins(), QBoxLayout::setGeometry(), QMdiSubWindowPrivate::setNewGeometry(), QtAndroidMenu::showContextMenu(), QMenu::sizeHint(), QMenuBar::sizeHint(), QQC2_NAMESPACE::QMacStyle::subElementRect(), QQC2::QCommonStyle::subElementRect(), QMacStyle::subElementRect(), QCommonStyle::subElementRect(), QQuickTreeViewPrivate::updateSelection(), and QLineEditPrivate::xToPos().

◆ y()

constexpr int QRect::y ( ) const
inlineconstexprnoexcept

Returns the y-coordinate of the rectangle's top edge.

Equivalent to top().

See also
setY(), x(), topLeft()

Definition at line 187 of file qrect.h.

Referenced by QWindowCreationContext::QWindowCreationContext(), QDialog::adjustPosition(), QStyle::alignedRect(), QQC2::QStyle::alignedRect(), QQnxScreen::availableGeometry(), QWaylandQtShellSurfacePrivate::configure(), QPathClipper::contains(), QQuickContext2DTile::createPainter(), QAndroidStyle::AndroidImageDrawable::draw(), QWindowsVistaStylePrivate::drawBackgroundThruNativeBuffer(), QQC2::QWindowsXPStylePrivate::drawBackgroundThruNativeBuffer(), QQC2::QCommonStyle::drawControl(), QCommonStyle::drawControl(), QWindows11Style::drawControl(), dom::drawImageToWebImageDataArray(), QGraphicsScenePrivate::drawItemHelper(), QQC2_NAMESPACE::QMacStyle::drawPrimitive(), QQC2::QCommonStyle::drawPrimitive(), QQC2::QWindowsStyle::drawPrimitive(), QAndroidStyle::drawPrimitive(), QMacStyle::drawPrimitive(), QCommonStyle::drawPrimitive(), QPaintEngine::drawRects(), QPainter::drawRects(), dumpNativeWindowsRecursion(), QOutlineMapper::endOutline(), QDockWidget::event(), QAlphaWidget::eventFilter(), QWindowsBackingStore::flush(), QXcbNativeBackingStore::flush(), QColorDialogPrivate::grabScreenColor(), grabScreenColor(), QWindowsScreen::grabWindow(), QQnxScreen::grabWindow(), QXcbScreen::grabWindow(), QBsdFbScreen::initialize(), QLinuxFbScreen::initialize(), QSpanData::initTexture(), QPathClipper::intersect(), QMdiSubWindow::keyPressEvent(), QWidgetResizeHandler::mouseMoveEvent(), QSizeGrip::mousePressEvent(), QWidget::move(), QAbstractButtonPrivate::moveFocus(), QTabBarPrivate::normalizedScrollRect(), operator<<(), operator<<(), QSGOpenVGPainterNode::paint(), QSGSoftwarePainterNode::paint(), QSGDefaultPainterNode::paint(), QPagePreview::paintEvent(), QLabel::paintEvent(), QTabWidget::paintEvent(), QTipLabel::placeTip(), QMenuBarPrivate::popupAction(), QWindowsDirect2DWindow::present(), qt_regionToPath(), QRasterPaintEnginePrivate::rasterize(), read_jpeg_image(), QWidgetPrivate::render_helper(), QSGRhiDistanceFieldGlyphCache::requestGlyphs(), QXcbNativeBackingStore::resize(), QQC2_NAMESPACE::rotateTabPainter(), QAlphaWidget::run(), QRollEffect::run(), QDockAreaLayoutInfo::saveState(), QWhatsThisPrivate::say(), QPolygonClipper< InType, OutType, CastType >::setBoundingRect(), QWindowsWindow::setCustomMargins(), QBoxLayout::setGeometry(), QFormLayout::setGeometry(), QMdiSubWindowPrivate::setNewGeometry(), QtAndroidMenu::showContextMenu(), QMenu::sizeHint(), QMenuBar::sizeHint(), QQC2_NAMESPACE::QMacStyle::subElementRect(), QQC2::QCommonStyle::subElementRect(), QMacStyle::subElementRect(), QCommonStyle::subElementRect(), and QQuickTreeViewPrivate::updateSelection().

Friends And Related Symbol Documentation

◆ operator!=

bool QRect::operator!= ( const QRect & r1,
const QRect & r2 )
friend

Returns true if the rectangles r1 and r2 are different, otherwise returns false.

Definition at line 124 of file qrect.h.

◆ operator+() [1/2]

QRect operator+ ( const QMargins & margins,
const QRect & rectangle )
related

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.Returns the rectangle grown by the margins.

Since
5.1

Definition at line 435 of file qrect.h.

◆ operator+() [2/2]

QRect operator+ ( const QRect & rectangle,
const QMargins & margins )
related

Returns the rectangle grown by the margins.

Since
5.1

Definition at line 429 of file qrect.h.

◆ operator-()

QRect operator- ( const QRect & lhs,
const QMargins & rhs )
related

Returns the lhs rectangle shrunk by the rhs margins.

Since
5.3

Definition at line 441 of file qrect.h.

◆ operator<<()

QDataStream & operator<< ( QDataStream & stream,
const QRect & rectangle )
related

Writes the given rectangle to the given stream, and returns a reference to the stream.

See also
{Serializing Qt Data Types}

Definition at line 1225 of file qrect.cpp.

◆ operator==

bool QRect::operator== ( const QRect & r1,
const QRect & r2 )
friend

Returns true if the rectangles r1 and r2 are equal, otherwise returns false.

Definition at line 122 of file qrect.h.

◆ operator>>()

QDataStream & operator>> ( QDataStream & stream,
QRect & rectangle )
related

Reads a rectangle from the given stream into the given rectangle, and returns a reference to the stream.

See also
{Serializing Qt Data Types}

Definition at line 1246 of file qrect.cpp.

◆ qHash

constexpr size_t qHash ( const QRect & r,
size_t seed = 0 )
friend

Definition at line 424 of file qrect.h.


The documentation for this class was generated from the following files: