Qt 4.8
Public Functions | Properties | Friends | Related Functions | List of all members
QRectF Class Reference

The QRectF class defines a rectangle in the plane using floating point precision. More...

#include <qrect.h>

Public Functions

void adjust (qreal x1, qreal y1, qreal x2, qreal y2)
 Adds dx1, dy1, dx2 and dy2 respectively to the existing coordinates of the rectangle. More...
 
QRectF adjusted (qreal x1, qreal y1, qreal x2, qreal y2) const
 Returns a new rectangle with dx1, dy1, dx2 and dy2 added respectively to the existing coordinates of this rectangle. More...
 
qreal bottom () const
 Returns the y-coordinate of the rectangle's bottom edge. More...
 
QPointF bottomLeft () const
 Returns the position of the rectangle's bottom-left corner. More...
 
QPointF bottomRight () const
 Returns the position of the rectangle's bottom-right corner. More...
 
QPointF center () const
 Returns the center point of the rectangle. More...
 
bool contains (const QPointF &p) const
 Returns true if the given point is inside or on the edge of the rectangle; otherwise returns false. More...
 
bool contains (qreal x, qreal y) const
 Returns true if the point (x, y) is inside or on the edge of the rectangle; otherwise returns false. More...
 
bool contains (const QRectF &r) const
 Returns true if the given rectangle is inside this rectangle; otherwise returns false. More...
 
void getCoords (qreal *x1, qreal *y1, qreal *x2, qreal *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. More...
 
void getRect (qreal *x, qreal *y, qreal *w, qreal *h) const
 Extracts the position of the rectangle's top-left corner to *x and y, and its dimensions to *width and *height. More...
 
qreal height () const
 Returns the height of the rectangle. More...
 
QRectF intersect (const QRectF &r) const
 Use intersected(rectangle) instead. More...
 
QRectF intersected (const QRectF &other) const
 Returns the intersection of this rectangle and the given rectangle. More...
 
bool intersects (const QRectF &r) const
 Returns true if this rectangle intersects with the given rectangle (i. More...
 
bool isEmpty () const
 Returns true if the rectangle is empty, otherwise returns false. More...
 
bool isNull () const
 Returns true if the rectangle is a null rectangle, otherwise returns false. More...
 
bool isValid () const
 Returns true if the rectangle is valid, otherwise returns false. More...
 
qreal left () const
 Returns the x-coordinate of the rectangle's left edge. More...
 
void moveBottom (qreal pos)
 Moves the rectangle vertically, leaving the rectangle's bottom edge at the given y coordinate. More...
 
void moveBottomLeft (const QPointF &p)
 Moves the rectangle, leaving the bottom-left corner at the given position. More...
 
void moveBottomRight (const QPointF &p)
 Moves the rectangle, leaving the bottom-right corner at the given position. More...
 
void moveCenter (const QPointF &p)
 Moves the rectangle, leaving the center point at the given position. More...
 
void moveLeft (qreal pos)
 Moves the rectangle horizontally, leaving the rectangle's left edge at the given x coordinate. More...
 
void moveRight (qreal pos)
 Moves the rectangle horizontally, leaving the rectangle's right edge at the given x coordinate. More...
 
void moveTo (qreal x, qreal t)
 Moves the rectangle, leaving the top-left corner at the given position (x, y). More...
 
void moveTo (const QPointF &p)
 Moves the rectangle, leaving the top-left corner at the given position. More...
 
void moveTop (qreal pos)
 Moves the rectangle vertically, leaving the rectangle's top line at the given y coordinate. More...
 
void moveTopLeft (const QPointF &p)
 Moves the rectangle, leaving the top-left corner at the given position. More...
 
void moveTopRight (const QPointF &p)
 Moves the rectangle, leaving the top-right corner at the given position. More...
 
QRectF normalized () const
 Returns a normalized rectangle; i.e., a rectangle that has a non-negative width and height. More...
 
QRectF operator & (const QRectF &r) const
 Returns the intersection of this rectangle and the given rectangle. More...
 
QRectFoperator &= (const QRectF &r)
 
QRectF operator| (const QRectF &r) const
 Returns the bounding rectangle of this rectangle and the given rectangle. More...
 
QRectFoperator|= (const QRectF &r)
 Unites this rectangle with the given rectangle. More...
 
 QRectF ()
 Constructs a null rectangle. More...
 
 QRectF (const QPointF &topleft, const QSizeF &size)
 Constructs a rectangle with the given topLeft corner and the given size. More...
 
 QRectF (const QPointF &topleft, const QPointF &bottomRight)
 Constructs a rectangle with the given topLeft and bottomRight corners. More...
 
 QRectF (qreal left, qreal top, qreal width, qreal height)
 Constructs a rectangle with (x, y) as its top-left corner and the given width and height. More...
 
 QRectF (const QRect &rect)
 Constructs a QRectF rectangle from the given QRect rectangle. More...
 
qreal right () const
 Returns the x-coordinate of the rectangle's right edge. More...
 
void setBottom (qreal pos)
 Sets the bottom edge of the rectangle to the given y coordinate. More...
 
void setBottomLeft (const QPointF &p)
 Set the bottom-left corner of the rectangle to the given position. More...
 
void setBottomRight (const QPointF &p)
 Set the bottom-right corner of the rectangle to the given position. More...
 
void setCoords (qreal x1, qreal y1, qreal x2, qreal y2)
 Sets the coordinates of the rectangle's top-left corner to (x1, y1), and the coordinates of its bottom-right corner to (x2, y2). More...
 
void setHeight (qreal h)
 Sets the height of the rectangle to the given height. More...
 
void setLeft (qreal pos)
 Sets the left edge of the rectangle to the given x coordinate. More...
 
void setRect (qreal x, qreal y, qreal w, qreal h)
 Sets the coordinates of the rectangle's top-left corner to (x, y), and its size to the given width and height. More...
 
void setRight (qreal pos)
 Sets the right edge of the rectangle to the given x coordinate. More...
 
void setSize (const QSizeF &s)
 Sets the size of the rectangle to the given size. More...
 
void setTop (qreal pos)
 Sets the top edge of the rectangle to the given y coordinate. More...
 
void setTopLeft (const QPointF &p)
 Set the top-left corner of the rectangle to the given position. More...
 
void setTopRight (const QPointF &p)
 Set the top-right corner of the rectangle to the given position. More...
 
void setWidth (qreal w)
 Sets the width of the rectangle to the given width. More...
 
void setX (qreal pos)
 Sets the left edge of the rectangle to the given x coordinate. More...
 
void setY (qreal pos)
 Sets the top edge of the rectangle to the given y coordinate. More...
 
QSizeF size () const
 Returns the size of the rectangle. More...
 
QRect toAlignedRect () const
 Returns a QRect based on the values of this rectangle that is the smallest possible integer rectangle that completely contains this rectangle. More...
 
qreal top () const
 Returns the y-coordinate of the rectangle's top edge. More...
 
QPointF topLeft () const
 Returns the position of the rectangle's top-left corner. More...
 
QPointF topRight () const
 Returns the position of the rectangle's top-right corner. More...
 
QRect toRect () const
 Returns a QRect based on the values of this rectangle. More...
 
void translate (qreal dx, qreal dy)
 Moves the rectangle dx along the x-axis and dy along the y-axis, relative to the current position. More...
 
void translate (const QPointF &p)
 Moves the rectangle {offset}. More...
 
QRectF translated (qreal dx, qreal dy) const
 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. More...
 
QRectF translated (const QPointF &p) const
 Returns a copy of the rectangle that is translated {offset}. More...
 
QRectF unite (const QRectF &r) const
 Use united(rectangle) instead. More...
 
QRectF united (const QRectF &other) const
 Returns the bounding rectangle of this rectangle and the given rectangle. More...
 
qreal width () const
 Returns the width of the rectangle. More...
 
qreal x () const
 Returns the x-coordinate of the rectangle's left edge. More...
 
qreal y () const
 Returns the y-coordinate of the rectangle's top edge. More...
 

Properties

qreal h
 
qreal w
 
qreal xp
 
qreal yp
 

Friends

Q_CORE_EXPORT_INLINE bool operator!= (const QRectF &, const QRectF &)
 Returns true if the rectangles r1 and r2 are different, otherwise returns false. More...
 
Q_CORE_EXPORT_INLINE bool operator== (const QRectF &, const QRectF &)
 Returns true if the rectangles r1 and r2 are equal, otherwise returns false. More...
 

Related Functions

(Note that these are not member functions.)

QDataStreamoperator<< (QDataStream &stream, const QRectF &rectangle)
 Writes the rectangle to the stream, and returns a reference to the stream. More...
 
QDataStreamoperator>> (QDataStream &stream, QRectF &rectangle)
 Reads a rectangle from the stream, and returns a reference to the stream. More...
 

Detailed Description

The QRectF class defines a rectangle in the plane using floating point precision.

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

A QRectF 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.

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

There is also a third constructor creating a QRectF from a QRect, and a corresponding toRect() function that returns a QRect object based on the values of this rectangle (note that the coordinates in the returned rectangle are rounded to the nearest integer).

The QRectF class provides a collection of functions that return the various rectangle coordinates, and enable manipulation of these. QRectF also provide 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 rectange'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 (otherwise false). The QRectF 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:

qrect-intersect.png
qrect-unite.png
intersected() united()

The isEmpty() function returns true if the rectangle's width or height is less than, or equal to, 0. Note that an empty rectangle is not valid: The isValid() function returns true if both width and height is larger than 0. 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 QRectF is defined in essentially the same way as QRect.

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

Rendering

When using an QPainter::Antialiasing{anti-aliased} painter, the boundary line of a QRectF will be rendered symmetrically on both sides of the mathematical rectangle's boundary line. But when using an aliased painter (the default) other rules apply.

Then, when rendering with a one pixel wide pen the QRectF's boundary line will be rendered to the right and below the mathematical rectangle's boundary line.

When rendering with a two pixels wide pen the boundary line will be split in the middle by the mathematical rectangle. This will be the case whenever the pen is set to an even number of pixels, while rendering with a pen with an odd number of pixels, the spare pixel will be rendered to the right and below the mathematical rectangle as in the one pixel case.

qrect-diagram-zero.png
qrectf-diagram-one.png
Logical representation One pixel wide pen
qrectf-diagram-two.png
qrectf-diagram-three.png
Two pixel wide pen Three pixel wide pen

Coordinates

The QRectF class provides a collection of functions that return the various rectangle coordinates, and enable manipulation of these. QRectF also provide functions to move the rectangle relative to the various coordinates.

For example: the bottom(), setBottom() and moveBottom() functions: bottom() returns the y-coordinate of the rectangle's bottom edge, setBottom() sets the bottom edge of the rectangle to the given y coordinate (it may change the height, but will never change the rectangle's top edge) and moveBottom() moves the entire rectangle vertically, leaving the rectangle's bottom edge at the given y coordinate and its size unchanged.

qrectf-coordinates.png

It is also possible to add offsets to this rectangle's coordinates using the adjust() function, as well as retrieve a new rectangle based on adjustments of the original one using the adjusted() function. If either of the width and height is negative, use the normalized() function to retrieve a rectangle where the corners are swapped.

In addition, QRectF provides the getCoords() function which extracts the position of the rectangle's top-left and bottom-right corner, and the getRect() function which extracts the rectangle's top-left corner, width and height. Use the setCoords() and setRect() function to manipulate the rectangle's coordinates and dimensions in one go.

See also
QRect, QRegion

Definition at line 511 of file qrect.h.

Constructors and Destructors

◆ QRectF() [1/5]

QRectF::QRectF ( )
inline

Constructs a null rectangle.

See also
isNull()

Definition at line 514 of file qrect.h.

Referenced by adjusted(), and translated().

514 { xp = yp = 0.; w = h = 0.; }
qreal xp
Definition: qrect.h:606
qreal h
Definition: qrect.h:609
qreal w
Definition: qrect.h:608
qreal yp
Definition: qrect.h:607

◆ QRectF() [2/5]

QRectF::QRectF ( const QPointF topLeft,
const QSizeF size 
)
inline

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

See also
setTopLeft(), setSize()

Definition at line 634 of file qrect.h.

635 {
636  xp = atopLeft.x();
637  yp = atopLeft.y();
638  w = asize.width();
639  h = asize.height();
640 }
qreal xp
Definition: qrect.h:606
qreal h
Definition: qrect.h:609
qreal w
Definition: qrect.h:608
qreal yp
Definition: qrect.h:607

◆ QRectF() [3/5]

QRectF::QRectF ( const QPointF topLeft,
const QPointF bottomRight 
)
inline

Constructs a rectangle with the given topLeft and bottomRight corners.

Since
4.3
See also
setTopLeft(), setBottomRight()

Definition at line 642 of file qrect.h.

643 {
644  xp = atopLeft.x();
645  yp = atopLeft.y();
646  w = abottomRight.x() - xp;
647  h = abottomRight.y() - yp;
648 }
qreal xp
Definition: qrect.h:606
qreal h
Definition: qrect.h:609
qreal w
Definition: qrect.h:608
qreal yp
Definition: qrect.h:607

◆ QRectF() [4/5]

QRectF::QRectF ( qreal  x,
qreal  y,
qreal  width,
qreal  height 
)
inline

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

See also
setRect()

Definition at line 629 of file qrect.h.

630  : xp(aleft), yp(atop), w(awidth), h(aheight)
631 {
632 }
qreal xp
Definition: qrect.h:606
qreal h
Definition: qrect.h:609
qreal w
Definition: qrect.h:608
qreal yp
Definition: qrect.h:607

◆ QRectF() [5/5]

QRectF::QRectF ( const QRect rectangle)
inline

Constructs a QRectF rectangle from the given QRect rectangle.

See also
toRect()

Definition at line 650 of file qrect.h.

651  : xp(r.x()), yp(r.y()), w(r.width()), h(r.height())
652 {
653 }
qreal xp
Definition: qrect.h:606
qreal h
Definition: qrect.h:609
qreal w
Definition: qrect.h:608
qreal yp
Definition: qrect.h:607

Functions

◆ adjust()

void QRectF::adjust ( qreal  dx1,
qreal  dy1,
qreal  dx2,
qreal  dy2 
)
inline

◆ adjusted()

QRectF QRectF::adjusted ( qreal  dx1,
qreal  dy1,
qreal  dx2,
qreal  dy2 
) const
inline

◆ bottom()

qreal QRectF::bottom ( ) const
inline

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

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

Definition at line 528 of file qrect.h.

Referenced by _q_boundGeometryToSizeConstraints(), QGL2PEXVertexArray::addQuad(), QGL2PEXVertexArray::addRect(), QmlJSDebugger::QDeclarativeViewInspector::adjustToScreenBoundaries(), QRenderRule::borderClip(), QGraphicsSceneBspTree::climbTree(), QBlitterPaintEnginePrivate::clipAndDrawPixmap(), QOpenGLPaintEnginePrivate::copyDrawable(), QTextDocumentLayout::draw(), QTextDocumentLayoutPrivate::drawBlock(), QTextDocumentLayoutPrivate::drawBorder(), QOpenGLPaintEnginePrivate::drawFastRect(), QTextDocumentLayoutPrivate::drawFlow(), QTextDocumentLayoutPrivate::drawFrame(), QRasterPaintEngine::drawImage(), QGL2PaintEngineEx::drawPixmap(), QGL2PaintEngineExPrivate::drawPixmapFragments(), QPaintEngineEx::drawRoundedRect(), QGL2PaintEngineEx::drawTexture(), drawTexture(), QOpenGLPaintEngine::drawTextureRect(), QOutlineMapper::endOutline(), QPlainTextEditPrivate::ensureVisible(), QGraphicsView::ensureVisible(), QGL2PaintEngineExPrivate::fill(), QBlitterPaintEngine::fillRect(), QIntersectionFinder::hasIntersections(), QPlainTextEditControl::hitTest(), QTextDocumentLayoutPrivate::hitTest(), QGraphicsSceneBspTree::initialize(), QPainterPath::intersects(), QTextDocumentLayoutPrivate::layoutBlock(), needsPerspectiveClipping(), QMatrix4x4::ortho(), QPlainTextEditPrivate::pageUpDown(), QPlainTextEdit::paintEvent(), QDashStroker::processCurrentSubpath(), QGLPixmapBlurFilter::processGL(), qMapGradientToRect(), qSubImage(), qt_isect_curve_horizontal(), qt_isect_curve_vertical(), qt_painterpath_check_crossing(), qt_painterpath_isect_line_rect(), qt_scale_image_16bit(), qt_scale_image_32bit(), qt_transform_image(), QRasterizer::rasterize(), QGraphicsViewPrivate::recalculateContentSize(), QGL2PaintEngineExPrivate::resetClipIfNeeded(), QmlJSDebugger::resizeRect(), QVGPaintEnginePrivate::roundedRectPath(), QGLEllipseMaskGenerator::screenRect(), QPainter::setClipRect(), QTextBrowserPrivate::setSource(), toAlignedRect_positive(), toNormalizedFillRect(), QAlphaPaintEnginePrivate::toRect(), QTest::toString(), QPaintBufferPrivate::updateBoundingRect(), QSGGeometry::updateRectGeometry(), ShaderEffect::updateRenderTargets(), QSGGeometry::updateTexturedRectGeometry(), QPlainTextEditPrivate::verticalOffset(), QGraphicsWidget::windowFrameSectionAt(), and QPicturePaintEngine::writeCmdLength().

528 { return yp + h; }
qreal h
Definition: qrect.h:609
qreal yp
Definition: qrect.h:607

◆ bottomLeft()

QPointF QRectF::bottomLeft ( ) const
inline

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

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

Definition at line 542 of file qrect.h.

Referenced by QPainterPath::contains(), QRasterPaintEngine::drawImage(), QVGPaintEngine::drawRects(), QRasterPaintEngine::drawRects(), QRasterPaintEngine::drawTiledPixmap(), QRasterPaintEngine::fill(), QVGPaintEngine::fillRect(), QRasterPaintEngine::fillRect(), QGraphicsView::mapFromScene(), QMatrix4x4::mapRect(), and QGraphicsViewPrivate::mapToScene().

542 { return QPointF(xp, yp+h); }
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
qreal xp
Definition: qrect.h:606
qreal h
Definition: qrect.h:609
qreal yp
Definition: qrect.h:607

◆ bottomRight()

QPointF QRectF::bottomRight ( ) const
inline

◆ center()

QPointF QRectF::center ( ) const
inline

◆ contains() [1/3]

bool QRectF::contains ( const QPointF point) const

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

See also
intersects()

Definition at line 2349 of file qrect.cpp.

Referenced by QPathClipper::clip(), QPathClipper::contains(), QPainterPath::contains(), contains(), QGraphicsTextItem::contains(), QPixmapConvolutionFilter::draw(), QGraphicsViewPrivate::findItems(), QDeclarativePathViewPrivate::handleMousePressEvent(), QGraphicsItemPrivate::initStyleOption(), QGraphicsSceneIndexRectIntersector::intersect(), QPathClipper::intersect(), QGraphicsSceneIndexPointIntersector::intersect(), QPainterPath::intersects(), QDeclarativeMouseArea::mouseMoveEvent(), QGraphicsItem::mousePressEvent(), QGraphicsTextItem::mouseReleaseEvent(), qt_format_text(), and QGraphicsWidget::windowFrameSectionAt().

2350 {
2351  qreal l = xp;
2352  qreal r = xp;
2353  if (w < 0)
2354  l += w;
2355  else
2356  r += w;
2357  if (l == r) // null rect
2358  return false;
2359 
2360  if (p.x() < l || p.x() > r)
2361  return false;
2362 
2363  qreal t = yp;
2364  qreal b = yp;
2365  if (h < 0)
2366  t += h;
2367  else
2368  b += h;
2369  if (t == b) // null rect
2370  return false;
2371 
2372  if (p.y() < t || p.y() > b)
2373  return false;
2374 
2375  return true;
2376 }
double qreal
Definition: qglobal.h:1193
qreal xp
Definition: qrect.h:606
qreal h
Definition: qrect.h:609
qreal w
Definition: qrect.h:608
QFactoryLoader * l
qreal yp
Definition: qrect.h:607

◆ contains() [2/3]

bool QRectF::contains ( qreal  x,
qreal  y 
) const
inline

Returns true if the point (x, y) is inside or on the edge of the rectangle; otherwise returns false.

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

Definition at line 796 of file qrect.h.

797 {
798  return contains(QPointF(ax, ay));
799 }
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
bool contains(const QPointF &p) const
Returns true if the given point is inside or on the edge of the rectangle; otherwise returns false...
Definition: qrect.cpp:2349

◆ contains() [3/3]

bool QRectF::contains ( const QRectF rectangle) const

Returns true if the given rectangle is inside this rectangle; otherwise returns false.

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

Definition at line 2401 of file qrect.cpp.

2402 {
2403  qreal l1 = xp;
2404  qreal r1 = xp;
2405  if (w < 0)
2406  l1 += w;
2407  else
2408  r1 += w;
2409  if (l1 == r1) // null rect
2410  return false;
2411 
2412  qreal l2 = r.xp;
2413  qreal r2 = r.xp;
2414  if (r.w < 0)
2415  l2 += r.w;
2416  else
2417  r2 += r.w;
2418  if (l2 == r2) // null rect
2419  return false;
2420 
2421  if (l2 < l1 || r2 > r1)
2422  return false;
2423 
2424  qreal t1 = yp;
2425  qreal b1 = yp;
2426  if (h < 0)
2427  t1 += h;
2428  else
2429  b1 += h;
2430  if (t1 == b1) // null rect
2431  return false;
2432 
2433  qreal t2 = r.yp;
2434  qreal b2 = r.yp;
2435  if (r.h < 0)
2436  t2 += r.h;
2437  else
2438  b2 += r.h;
2439  if (t2 == b2) // null rect
2440  return false;
2441 
2442  if (t2 < t1 || b2 > b1)
2443  return false;
2444 
2445  return true;
2446 }
double qreal
Definition: qglobal.h:1193
qreal xp
Definition: qrect.h:606
qreal h
Definition: qrect.h:609
qreal w
Definition: qrect.h:608
qreal yp
Definition: qrect.h:607

◆ getCoords()

void QRectF::getCoords ( qreal x1,
qreal y1,
qreal x2,
qreal y2 
) const
inline

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 762 of file qrect.h.

763 {
764  *xp1 = xp;
765  *yp1 = yp;
766  *xp2 = xp + w;
767  *yp2 = yp + h;
768 }
qreal xp
Definition: qrect.h:606
qreal h
Definition: qrect.h:609
qreal w
Definition: qrect.h:608
qreal yp
Definition: qrect.h:607

◆ getRect()

void QRectF::getRect ( qreal x,
qreal y,
qreal width,
qreal height 
) const
inline

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 746 of file qrect.h.

Referenced by _q_interpolate().

747 {
748  *ax = this->xp;
749  *ay = this->yp;
750  *aaw = this->w;
751  *aah = this->h;
752 }
qreal xp
Definition: qrect.h:606
qreal h
Definition: qrect.h:609
qreal w
Definition: qrect.h:608
qreal yp
Definition: qrect.h:607

◆ height()

qreal QRectF::height ( ) const
inline

Returns the height of the rectangle.

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

Definition at line 710 of file qrect.h.

Referenced by _q_adjustRect(), QPlainTextEditPrivate::_q_adjustScrollbars(), _q_boundGeometryToSizeConstraints(), QPainterPath::addEllipse(), QGL2PEXVertexArray::addPath(), QPathSegments::addPath(), QPainterPath::addRect(), QPainterPath::addRoundedRect(), QPainterPath::addRoundRect(), QPainterPath::arcTo(), QPlainTextEditControl::blockBoundingRect(), QDeclarativeItemPrivate::computeTransformOrigin(), QPathClipper::contains(), QOpenGLPaintEnginePrivate::copyDrawable(), QPainter::PixmapFragment::create(), createRectNode(), QTriangulatingStroker::cubicTo(), QGraphicsSceneBspTree::debug(), QPlainTextDocumentLayout::documentChanged(), QTextLayout::draw(), QAlphaPaintEnginePrivate::drawAlphaImage(), QPainter::drawArc(), QTextDocumentLayoutPrivate::drawBlock(), QPainter::drawChord(), QCoreGraphicsPaintEngine::drawEllipse(), QVGPaintEngine::drawEllipse(), QRasterPaintEngine::drawEllipse(), QPainter::drawEllipse(), QTextDocumentLayoutPrivate::drawFrameDecoration(), QPdfEngine::drawImage(), QCoreGraphicsPaintEngine::drawImage(), QX11PaintEngine::drawImage(), QVGPaintEngine::drawImage(), QSvgPaintEngine::drawImage(), QPaintEngine::drawImage(), QRasterPaintEngine::drawImage(), QPainter::drawImage(), QOpenGLPaintEnginePrivate::drawImageAsPath(), QPSPrintEngine::drawImageInternal(), drawImageTiled(), QGraphicsScenePrivate::drawItemHelper(), QGLEllipseMaskGenerator::drawMask(), QPainter::drawPath(), QPainter::drawPie(), QWin32PrintEngine::drawPixmap(), QPdfEngine::drawPixmap(), QCoreGraphicsPaintEngine::drawPixmap(), QX11PaintEngine::drawPixmap(), QPainter::drawPixmap(), QVGPaintEngine::drawPixmapFragments(), QVGPaintEngine::drawRects(), QPaintEngine::drawRects(), QPaintEngineEx::drawRects(), QRasterPaintEngine::drawRects(), QPdfBaseEngine::drawRects(), QPainter::drawRects(), QPaintEngineEx::drawRoundedRect(), QPainter::drawRoundedRect(), QTextDocumentLayoutPrivate::drawTableCell(), QPainter::drawText(), QPSPrintEngine::drawTiledPixmap(), QWin32PrintEngine::drawTiledPixmap(), QCoreGraphicsPaintEngine::drawTiledPixmap(), QX11PaintEngine::drawTiledPixmap(), QOpenGLPaintEngine::drawTiledPixmap(), QPaintEngine::drawTiledPixmap(), QRasterPaintEngine::drawTiledPixmap(), QPaintEngineEx::drawTiledPixmap(), QPainter::drawTiledPixmap(), drawVGImage(), QPdfEnginePrivate::embedFont(), QOutlineMapper::endOutline(), QPlainTextEditPrivate::ensureVisible(), QScriptEdit::extraAreaPaintEvent(), QEmulationPaintEngine::fill(), QRasterPaintEngine::fill(), QEmulationPaintEngine::fillBGRect(), QVGPaintEngine::fillRect(), QPaintEngineEx::fillRect(), QBlitterPaintEnginePrivate::fillRect(), QRasterPaintEngine::fillRect(), QGridLayoutEngine::fillRowData(), QGraphicsView::fitInView(), QDeclarativeCompiler::genLiteralAssignment(), QDeclarativePaintedItem::geometryChanged(), QDeclarativeItem::geometryChanged(), QDeclarativeFlickable::geometryChanged(), QGraphicsScene::height(), QPlainTextEditControl::hitTest(), QGraphicsSceneBspTree::initialize(), QPathClipper::intersect(), QDeclarativeLoaderPrivate::itemGeometryChanged(), QDeclarativeContents::itemGeometryChanged(), QDeclarativeAnchorsPrivate::itemGeometryChanged(), QDeclarativeGridViewPrivate::itemGeometryChanged(), QDeclarativeListViewPrivate::itemGeometryChanged(), QTextDocumentLayoutPrivate::layoutBlock(), QTextDocumentLayoutPrivate::layoutFlow(), QLabelPrivate::layoutRect(), QSvgIOHandlerPrivate::load(), QMacPixmapData::macCreatePixels(), QMatrix::mapRect(), QTransform::mapRect(), QMatrix4x4::mapRect(), QSvgTinyDocument::mapSourceToTarget(), QPaintBuffer::metric(), QmlJSDebugger::ZoomTool::mouseReleaseEvent(), operator<<(), QPlainTextEditPrivate::pageUpDown(), QFontFamilyDelegate::paint(), QDeclarativeParticlesPainter::paint(), QPlainTextEdit::paintEvent(), printPage(), QDashedStrokeProcessor::process(), QGLPixmapBlurFilter::processGL(), qDrawBorder(), QPolygonF::QPolygonF(), QRectF_intersects(), qt_curves_for_arc(), qt_find_ellipse_coords(), qt_format_text(), qt_graphicsItem_highlightSelected(), qt_isect_curve_horizontal(), qt_isect_curve_vertical(), qt_mac_compose_rect(), qt_mac_create_imagemask(), qt_painterpath_isect_curve(), qt_scale_image_16bit(), qt_scale_image_32bit(), qt_scale_image_argb24_on_rgb16(), qt_scale_image_argb32_on_argb32(), qt_scale_image_argb32_on_rgb16(), qt_scale_image_rgb16_on_rgb16(), qt_scale_image_rgb32_on_rgb32(), QGraphicsViewPrivate::recalculateContentSize(), QGraphicsScene::render(), QGraphicsView::render(), QPaintEngineExPrivate::replayClipOperations(), QVGPaintEnginePrivate::roundedRectPath(), scaleRect(), QPainter::setClipPath(), QPainter::setClipRect(), QDeclarativeLayoutItem::setGeometry(), QX11WindowSurface::setGeometry(), setPenAndDrawBackground(), QTextBrowserPrivate::setSource(), QDeclarativeTextPrivate::setupTextLayout(), QDeclarativeRectFValueType::setY(), shift(), stretchGradientToUserSpace(), QEmulationPaintEngine::stroke(), toRect_normalized(), QTest::toString(), glyph_metrics_t::transformed(), ShaderEffectItem::updateEffectState(), ShaderEffectItem::updateGeometry(), and QPicturePaintEngine::writeCmdLength().

711 { return h; }
qreal h
Definition: qrect.h:609

◆ intersect()

QRectF QRectF::intersect ( const QRectF rectangle) const
inline

Use intersected(rectangle) instead.

Definition at line 813 of file qrect.h.

Referenced by intersected().

814 {
815  return *this & r;
816 }

◆ intersected()

QRectF QRectF::intersected ( const QRectF rectangle) const
inline

Returns the intersection of this rectangle and the given rectangle.

Since
4.2

Note that {r.intersected(s)} is equivalent to {r & s}.

qrect-intersect.png
See also
intersects(), united(), operator&=()

Definition at line 818 of file qrect.h.

Referenced by QTextEditPrivate::_q_repaintContents(), QPlainTextEditPrivate::_q_repaintContents(), QBlitterPaintEnginePrivate::clipAndDrawPixmap(), QTextLayout::draw(), and QPainterPrivate::draw_helper().

819 {
820  return intersect(r);
821 }
QRectF intersect(const QRectF &r) const
Use intersected(rectangle) instead.
Definition: qrect.h:813

◆ intersects()

bool QRectF::intersects ( const QRectF rectangle) const

Returns true if this rectangle intersects with the given rectangle (i.

e. there is a non-empty area of overlap between them), otherwise returns false.

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

See also
contains()

Definition at line 2744 of file qrect.cpp.

Referenced by QGraphicsTextItemPrivate::_q_update(), QPathClipper::clip(), QGraphicsItem::collidesWithPath(), QGraphicsSceneIndexRectIntersector::intersect(), QGraphicsSceneIndexPointIntersector::intersect(), QGraphicsItem::scroll(), QTextBrowserPrivate::setSource(), and QPainterPath::toFillPolygons().

2745 {
2746  qreal l1 = xp;
2747  qreal r1 = xp;
2748  if (w < 0)
2749  l1 += w;
2750  else
2751  r1 += w;
2752  if (l1 == r1) // null rect
2753  return false;
2754 
2755  qreal l2 = r.xp;
2756  qreal r2 = r.xp;
2757  if (r.w < 0)
2758  l2 += r.w;
2759  else
2760  r2 += r.w;
2761  if (l2 == r2) // null rect
2762  return false;
2763 
2764  if (l1 >= r2 || l2 >= r1)
2765  return false;
2766 
2767  qreal t1 = yp;
2768  qreal b1 = yp;
2769  if (h < 0)
2770  t1 += h;
2771  else
2772  b1 += h;
2773  if (t1 == b1) // null rect
2774  return false;
2775 
2776  qreal t2 = r.yp;
2777  qreal b2 = r.yp;
2778  if (r.h < 0)
2779  t2 += r.h;
2780  else
2781  b2 += r.h;
2782  if (t2 == b2) // null rect
2783  return false;
2784 
2785  if (t1 >= b2 || t2 >= b1)
2786  return false;
2787 
2788  return true;
2789 }
double qreal
Definition: qglobal.h:1193
qreal xp
Definition: qrect.h:606
qreal h
Definition: qrect.h:609
qreal w
Definition: qrect.h:608
qreal yp
Definition: qrect.h:607

◆ isEmpty()

bool QRectF::isEmpty ( ) const
inline

◆ isNull()

bool QRectF::isNull ( ) const
inline

◆ isValid()

bool QRectF::isValid ( ) const
inline

◆ left()

qreal QRectF::left ( ) const
inline

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

Equivalent to x().

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

Definition at line 525 of file qrect.h.

Referenced by _q_boundGeometryToSizeConstraints(), QPrintPreviewWidgetPrivate::_q_fit(), QGL2PEXVertexArray::addQuad(), QGL2PEXVertexArray::addRect(), addSelectedRegionsToPath(), QmlJSDebugger::QDeclarativeViewInspector::adjustToScreenBoundaries(), QRenderRule::borderClip(), QGraphicsSceneBspTree::climbTree(), QBlitterPaintEnginePrivate::clipAndDrawPixmap(), QOpenGLPaintEnginePrivate::copyDrawable(), QPlainTextEditControl::cursorRect(), QGraphicsSceneBspTree::debug(), QTextDocumentLayoutPrivate::drawBlock(), QTextDocumentLayoutPrivate::drawBorder(), QOpenGLPaintEnginePrivate::drawFastRect(), QTextDocumentLayoutPrivate::drawFrame(), QTextDocumentLayoutPrivate::drawFrameDecoration(), QRasterPaintEngine::drawImage(), QOpenGLPaintEnginePrivate::drawImageAsPath(), QTextDocumentLayoutPrivate::drawListItem(), QGL2PaintEngineEx::drawPixmap(), QGL2PaintEngineExPrivate::drawPixmapFragments(), QPaintEngineEx::drawRoundedRect(), QTextDocumentLayoutPrivate::drawTableCell(), QGL2PaintEngineEx::drawTexture(), drawTexture(), QOpenGLPaintEnginePrivate::drawTiledImageAsPath(), QWin32PrintEngine::drawTiledPixmap(), QOutlineMapper::endOutline(), QGraphicsView::ensureVisible(), QGL2PaintEngineExPrivate::fill(), QIntersectionFinder::hasIntersections(), QTextDocumentLayoutPrivate::hitTest(), QGraphicsSceneBspTree::initialize(), QPainterPath::intersects(), needsPerspectiveClipping(), QMatrix4x4::ortho(), QDeclarativeParticlesPainter::paint(), printPage(), QDashStroker::processCurrentSubpath(), QGLPixmapDropShadowFilter::processGL(), qDrawBorder(), QRectF_intersects(), qSubImage(), qt_isect_curve_horizontal(), qt_isect_curve_vertical(), qt_painterpath_check_crossing(), qt_painterpath_isect_line_rect(), qt_scale_image_16bit(), qt_scale_image_32bit(), qt_transform_image(), QGraphicsViewPrivate::recalculateContentSize(), QGraphicsScene::render(), QGraphicsView::render(), QGL2PaintEngineExPrivate::resetClipIfNeeded(), QmlJSDebugger::resizeRect(), QVGPaintEnginePrivate::roundedRectPath(), QGLEllipseMaskGenerator::screenRect(), QTextControl::selectionRect(), QPainter::setClipRect(), QGraphicsAnchorLayoutPrivate::setItemsGeometries(), QDeclarativeTextPrivate::setupTextLayout(), QAlphaPaintEnginePrivate::toRect(), QTest::toString(), QPaintBufferPrivate::updateBoundingRect(), ShaderEffectItem::updateGeometry(), QSGGeometry::updateRectGeometry(), ShaderEffect::updateRenderTargets(), QSGGeometry::updateTexturedRectGeometry(), visualRect(), QGraphicsWidget::windowFrameSectionAt(), and QPicturePaintEngine::writeCmdLength().

525 { return xp; }
qreal xp
Definition: qrect.h:606

◆ moveBottom()

void QRectF::moveBottom ( qreal  y)
inline

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 695 of file qrect.h.

Referenced by moveBottomLeft(), and moveBottomRight().

695 { yp = pos - h; }
qreal h
Definition: qrect.h:609
qreal yp
Definition: qrect.h:607

◆ moveBottomLeft()

void QRectF::moveBottomLeft ( const QPointF position)
inline

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 701 of file qrect.h.

Referenced by QBlittablePixmapData::markRasterOverlay().

701 { moveLeft(p.x()); moveBottom(p.y()); }
void moveLeft(qreal pos)
Moves the rectangle horizontally, leaving the rectangle&#39;s left edge at the given x coordinate...
Definition: qrect.h:689
void moveBottom(qreal pos)
Moves the rectangle vertically, leaving the rectangle&#39;s bottom edge at the given y coordinate...
Definition: qrect.h:695

◆ moveBottomRight()

void QRectF::moveBottomRight ( const QPointF position)
inline

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

The rectangle's size is unchanged.

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

Definition at line 703 of file qrect.h.

703 { moveRight(p.x()); moveBottom(p.y()); }
void moveBottom(qreal pos)
Moves the rectangle vertically, leaving the rectangle&#39;s bottom edge at the given y coordinate...
Definition: qrect.h:695
void moveRight(qreal pos)
Moves the rectangle horizontally, leaving the rectangle&#39;s right edge at the given x coordinate...
Definition: qrect.h:693

◆ moveCenter()

void QRectF::moveCenter ( const QPointF position)
inline

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

The rectangle's size is unchanged.

See also
center()

Definition at line 705 of file qrect.h.

Referenced by QApplication::notify(), QTouchEvent::TouchPoint::setPos(), QTouchEvent::TouchPoint::setScenePos(), QTouchEvent::TouchPoint::setScreenPos(), QApplicationPrivate::translateTouchEvent(), and QApplicationPrivate::updateTouchPointsForWidget().

705 { xp = p.x() - w/2; yp = p.y() - h/2; }
qreal xp
Definition: qrect.h:606
qreal h
Definition: qrect.h:609
qreal w
Definition: qrect.h:608
qreal yp
Definition: qrect.h:607

◆ moveLeft()

void QRectF::moveLeft ( qreal  x)
inline

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 689 of file qrect.h.

Referenced by addSelectedRegionsToPath(), moveBottomLeft(), moveTopLeft(), and QDeclarativeRectFValueType::setX().

689 { xp = pos; }
qreal xp
Definition: qrect.h:606

◆ moveRight()

void QRectF::moveRight ( qreal  x)
inline

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 693 of file qrect.h.

Referenced by moveBottomRight(), moveTopRight(), and visualRect().

693 { xp = pos - w; }
qreal xp
Definition: qrect.h:606
qreal w
Definition: qrect.h:608

◆ moveTo() [1/2]

void QRectF::moveTo ( qreal  x,
qreal  y 
)
inline

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 728 of file qrect.h.

Referenced by convolute(), and QGraphicsProxyWidgetPrivate::updateProxyGeometryFromWidget().

729 {
730  xp = ax;
731  yp = ay;
732 }
qreal xp
Definition: qrect.h:606
qreal yp
Definition: qrect.h:607

◆ moveTo() [2/2]

void QRectF::moveTo ( const QPointF position)
inline

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

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

Definition at line 734 of file qrect.h.

735 {
736  xp = p.x();
737  yp = p.y();
738 }
qreal xp
Definition: qrect.h:606
qreal yp
Definition: qrect.h:607

◆ moveTop()

void QRectF::moveTop ( qreal  y)
inline

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

The rectangle's size is unchanged.

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

Definition at line 691 of file qrect.h.

Referenced by QPrintPreviewWidgetPrivate::_q_fit(), addSelectedRegionsToPath(), moveTopLeft(), moveTopRight(), and QDeclarativeRectFValueType::setY().

691 { yp = pos; }
qreal yp
Definition: qrect.h:607

◆ moveTopLeft()

void QRectF::moveTopLeft ( const QPointF position)
inline

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 697 of file qrect.h.

Referenced by QTextDocumentLayout::blockBoundingRect(), and QGraphicsWidget::setGeometry().

697 { moveLeft(p.x()); moveTop(p.y()); }
void moveTop(qreal pos)
Moves the rectangle vertically, leaving the rectangle&#39;s top line at the given y coordinate.
Definition: qrect.h:691
void moveLeft(qreal pos)
Moves the rectangle horizontally, leaving the rectangle&#39;s left edge at the given x coordinate...
Definition: qrect.h:689

◆ moveTopRight()

void QRectF::moveTopRight ( const QPointF position)
inline

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 699 of file qrect.h.

699 { moveRight(p.x()); moveTop(p.y()); }
void moveTop(qreal pos)
Moves the rectangle vertically, leaving the rectangle&#39;s top line at the given y coordinate.
Definition: qrect.h:691
void moveRight(qreal pos)
Moves the rectangle horizontally, leaving the rectangle&#39;s right edge at the given x coordinate...
Definition: qrect.h:693

◆ normalized()

QRectF QRectF::normalized ( ) const

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.

See also
isValid(), isEmpty()

Definition at line 1822 of file qrect.cpp.

Referenced by QPainterPath::addRoundedRect(), QPainterPath::addRoundRect(), QPainter::drawArc(), QPainter::drawChord(), QPainter::drawEllipse(), QRasterPaintEngine::drawImage(), QPainter::drawPie(), QRasterPaintEngine::drawRects(), QRasterPaintEngine::drawTiledPixmap(), QRasterPaintEngine::fill(), QRasterPaintEngine::fillRect(), QPainterPath::intersects(), QRasterPaintEnginePrivate::isUnclipped(), and QMacPixmapData::macCreatePixels().

1823 {
1824  QRectF r = *this;
1825  if (r.w < 0) {
1826  r.xp += r.w;
1827  r.w = -r.w;
1828  }
1829  if (r.h < 0) {
1830  r.yp += r.h;
1831  r.h = -r.h;
1832  }
1833  return r;
1834 }
qreal xp
Definition: qrect.h:606
qreal h
Definition: qrect.h:609
The QRectF class defines a rectangle in the plane using floating point precision. ...
Definition: qrect.h:511
qreal w
Definition: qrect.h:608
qreal yp
Definition: qrect.h:607

◆ operator &()

QRectF QRectF::operator& ( const QRectF rectangle) const

Returns the intersection of this rectangle and the given rectangle.

Returns an empty rectangle if there is no intersection.

See also
operator&=(), intersected()

Referenced by operator|().

◆ operator &=()

QRectF& QRectF::operator&= ( const QRectF r)

Referenced by operator|=().

◆ operator|()

QRectF QRectF::operator| ( const QRectF rectangle) const

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

See also
united(), operator|=()

Definition at line 2572 of file qrect.cpp.

2573 {
2574  if (isNull())
2575  return r;
2576  if (r.isNull())
2577  return *this;
2578 
2579  qreal left = xp;
2580  qreal right = xp;
2581  if (w < 0)
2582  left += w;
2583  else
2584  right += w;
2585 
2586  if (r.w < 0) {
2587  left = qMin(left, r.xp + r.w);
2588  right = qMax(right, r.xp);
2589  } else {
2590  left = qMin(left, r.xp);
2591  right = qMax(right, r.xp + r.w);
2592  }
2593 
2594  qreal top = yp;
2595  qreal bottom = yp;
2596  if (h < 0)
2597  top += h;
2598  else
2599  bottom += h;
2600 
2601  if (r.h < 0) {
2602  top = qMin(top, r.yp + r.h);
2603  bottom = qMax(bottom, r.yp);
2604  } else {
2605  top = qMin(top, r.yp);
2606  bottom = qMax(bottom, r.yp + r.h);
2607  }
2608 
2609  return QRectF(left, top, right - left, bottom - top);
2610 }
qreal right() const
Returns the x-coordinate of the rectangle&#39;s right edge.
Definition: qrect.h:527
double qreal
Definition: qglobal.h:1193
Q_DECL_CONSTEXPR const T & qMin(const T &a, const T &b)
Definition: qglobal.h:1215
qreal left() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:525
qreal xp
Definition: qrect.h:606
qreal h
Definition: qrect.h:609
Q_DECL_CONSTEXPR const T & qMax(const T &a, const T &b)
Definition: qglobal.h:1217
qreal w
Definition: qrect.h:608
QRectF()
Constructs a null rectangle.
Definition: qrect.h:514
qreal top() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:526
qreal yp
Definition: qrect.h:607
qreal bottom() const
Returns the y-coordinate of the rectangle&#39;s bottom edge.
Definition: qrect.h:528
bool isNull() const
Returns true if the rectangle is a null rectangle, otherwise returns false.
Definition: qrect.h:655

◆ operator|=()

QRectF & QRectF::operator|= ( const QRectF rectangle)
inline

Unites this rectangle with the given rectangle.

See also
united(), operator|()

Definition at line 801 of file qrect.h.

802 {
803  *this = *this | r;
804  return *this;
805 }

◆ right()

qreal QRectF::right ( ) const
inline

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

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

Definition at line 527 of file qrect.h.

Referenced by _q_boundGeometryToSizeConstraints(), QPrintPreviewWidgetPrivate::_q_fit(), QGL2PEXVertexArray::addQuad(), QGL2PEXVertexArray::addRect(), QmlJSDebugger::QDeclarativeViewInspector::adjustToScreenBoundaries(), QRenderRule::borderClip(), QDeclarativeTextInput::boundingRect(), QDeclarativeTextEdit::boundingRect(), QGraphicsSceneBspTree::climbTree(), QBlitterPaintEnginePrivate::clipAndDrawPixmap(), QTextDocumentLayoutPrivate::drawBorder(), QOpenGLPaintEnginePrivate::drawFastRect(), QTextDocumentLayoutPrivate::drawFrame(), QRasterPaintEngine::drawImage(), QTextDocumentLayoutPrivate::drawListItem(), QGL2PaintEngineEx::drawPixmap(), QGL2PaintEngineExPrivate::drawPixmapFragments(), QPaintEngineEx::drawRoundedRect(), QGL2PaintEngineEx::drawTexture(), drawTexture(), QOpenGLPaintEngine::drawTextureRect(), QOutlineMapper::endOutline(), QGraphicsView::ensureVisible(), QGL2PaintEngineExPrivate::fill(), QBlitterPaintEngine::fillRect(), QIntersectionFinder::hasIntersections(), QTextDocumentLayoutPrivate::hitTest(), QGraphicsSceneBspTree::initialize(), QPainterPath::intersects(), needsPerspectiveClipping(), QMatrix4x4::ortho(), QDashStroker::processCurrentSubpath(), qSubImage(), qt_isect_curve_horizontal(), qt_isect_curve_vertical(), qt_painterpath_check_crossing(), qt_painterpath_isect_line_rect(), qt_scale_image_16bit(), qt_scale_image_32bit(), qt_transform_image(), QGraphicsViewPrivate::recalculateContentSize(), QGL2PaintEngineExPrivate::resetClipIfNeeded(), QmlJSDebugger::resizeRect(), QVGPaintEnginePrivate::roundedRectPath(), QGLEllipseMaskGenerator::screenRect(), QTextControl::selectionRect(), QPainter::setClipRect(), QGraphicsAnchorLayoutPrivate::setItemsGeometries(), QDeclarativeTextPrivate::setupTextLayout(), toAlignedRect_positive(), toNormalizedFillRect(), QAlphaPaintEnginePrivate::toRect(), QTest::toString(), QPaintBufferPrivate::updateBoundingRect(), QSGGeometry::updateRectGeometry(), ShaderEffect::updateRenderTargets(), QSGGeometry::updateTexturedRectGeometry(), visualRect(), QGraphicsWidget::windowFrameSectionAt(), and QPicturePaintEngine::writeCmdLength().

527 { return xp + w; }
qreal xp
Definition: qrect.h:606
qreal w
Definition: qrect.h:608

◆ setBottom()

void QRectF::setBottom ( qreal  y)
inline

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 676 of file qrect.h.

Referenced by QmlJSDebugger::QDeclarativeViewInspector::adjustToScreenBoundaries(), blitTexture(), QTextDocumentLayoutPrivate::drawBorder(), drawTexture(), QTextDocumentLayoutPrivate::layoutBlock(), QGraphicsSceneBspTree::rectForIndex(), QmlJSDebugger::resizeRect(), setBottomLeft(), setBottomRight(), and QGraphicsAnchorLayoutPrivate::setItemsGeometries().

676 { h = pos - yp; }
qreal h
Definition: qrect.h:609
qreal yp
Definition: qrect.h:607

◆ setBottomLeft()

void QRectF::setBottomLeft ( const QPointF position)
inline

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 682 of file qrect.h.

682 { setLeft(p.x()); setBottom(p.y()); }
void setLeft(qreal pos)
Sets the left edge of the rectangle to the given x coordinate.
Definition: qrect.h:670
void setBottom(qreal pos)
Sets the bottom edge of the rectangle to the given y coordinate.
Definition: qrect.h:676

◆ setBottomRight()

void QRectF::setBottomRight ( const QPointF position)
inline

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 684 of file qrect.h.

684 { setRight(p.x()); setBottom(p.y()); }
void setBottom(qreal pos)
Sets the bottom edge of the rectangle to the given y coordinate.
Definition: qrect.h:676
void setRight(qreal pos)
Sets the right edge of the rectangle to the given x coordinate.
Definition: qrect.h:672

◆ setCoords()

void QRectF::setCoords ( qreal  x1,
qreal  y1,
qreal  x2,
qreal  y2 
)
inline

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 770 of file qrect.h.

Referenced by QPathClipper::pathToRect(), and QPicturePaintEngine::writeCmdLength().

771 {
772  xp = xp1;
773  yp = yp1;
774  w = xp2 - xp1;
775  h = yp2 - yp1;
776 }
qreal xp
Definition: qrect.h:606
qreal h
Definition: qrect.h:609
qreal w
Definition: qrect.h:608
qreal yp
Definition: qrect.h:607

◆ setHeight()

void QRectF::setHeight ( qreal  height)
inline

Sets the height of the rectangle to the given height.

The bottom edge is changed, but not the top one.

See also
height(), setSize()

Definition at line 787 of file qrect.h.

Referenced by _q_boundGeometryToSizeConstraints(), QSvgText::draw(), QTextDocumentLayoutPrivate::drawFrameDecoration(), QDeclarativeRectFValueType::setHeight(), QDeclarativeTextPrivate::setupTextLayout(), and QGraphicsWidget::windowFrameSectionAt().

788 { this->h = ah; }
qreal h
Definition: qrect.h:609

◆ setLeft()

void QRectF::setLeft ( qreal  x)
inline

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 setX().

See also
left(), moveLeft()

Definition at line 670 of file qrect.h.

Referenced by QPrintPreviewWidgetPrivate::_q_fit(), QmlJSDebugger::QDeclarativeViewInspector::adjustToScreenBoundaries(), blitTexture(), QPlainTextEditControl::cursorRect(), drawTexture(), QGraphicsSceneBspTree::rectForIndex(), QmlJSDebugger::resizeRect(), QTextControl::selectionRect(), setBottomLeft(), QTextControl::setExtraSelections(), QGraphicsAnchorLayoutPrivate::setItemsGeometries(), and setTopLeft().

670 { qreal diff = pos - xp; xp += diff; w -= diff; }
double qreal
Definition: qglobal.h:1193
qreal xp
Definition: qrect.h:606
qreal w
Definition: qrect.h:608
static Bigint * diff(Bigint *a, Bigint *b)

◆ setRect()

void QRectF::setRect ( qreal  x,
qreal  y,
qreal  width,
qreal  height 
)
inline

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 754 of file qrect.h.

Referenced by _q_boundGeometryToSizeConstraints(), QGraphicsSceneBspTree::initialize(), operator>>(), QGraphicsScene::render(), QGraphicsView::render(), and QmlJSDebugger::ZoomTool::scaleView().

755 {
756  this->xp = ax;
757  this->yp = ay;
758  this->w = aaw;
759  this->h = aah;
760 }
qreal xp
Definition: qrect.h:606
qreal h
Definition: qrect.h:609
qreal w
Definition: qrect.h:608
qreal yp
Definition: qrect.h:607

◆ setRight()

void QRectF::setRight ( qreal  x)
inline

◆ setSize()

void QRectF::setSize ( const QSizeF size)
inline

Sets the size of the rectangle to the given size.

The top-left corner is not moved.

See also
size(), setWidth(), setHeight()

Definition at line 790 of file qrect.h.

Referenced by QGraphicsTextItemPrivate::_q_updateBoundingRect(), QGraphicsWidget::setGeometry(), QGraphicsTextItemPrivate::textControl(), QApplicationPrivate::translateTouchEvent(), QGraphicsSvgItemPrivate::updateDefaultSize(), and QGraphicsProxyWidgetPrivate::updateProxyGeometryFromWidget().

791 {
792  w = s.width();
793  h = s.height();
794 }
qreal h
Definition: qrect.h:609
qreal w
Definition: qrect.h:608

◆ setTop()

void QRectF::setTop ( qreal  y)
inline

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 674 of file qrect.h.

Referenced by _q_boundGeometryToSizeConstraints(), QmlJSDebugger::QDeclarativeViewInspector::adjustToScreenBoundaries(), blitTexture(), QTextDocumentLayoutPrivate::drawBorder(), drawTexture(), QTextDocumentLayoutPrivate::layoutBlock(), QGraphicsSceneBspTree::rectForIndex(), QmlJSDebugger::resizeRect(), QGraphicsAnchorLayoutPrivate::setItemsGeometries(), setTopLeft(), and setTopRight().

674 { qreal diff = pos - yp; yp += diff; h -= diff; }
double qreal
Definition: qglobal.h:1193
qreal h
Definition: qrect.h:609
static Bigint * diff(Bigint *a, Bigint *b)
qreal yp
Definition: qrect.h:607

◆ setTopLeft()

void QRectF::setTopLeft ( const QPointF position)
inline

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 678 of file qrect.h.

678 { setLeft(p.x()); setTop(p.y()); }
void setLeft(qreal pos)
Sets the left edge of the rectangle to the given x coordinate.
Definition: qrect.h:670
void setTop(qreal pos)
Sets the top edge of the rectangle to the given y coordinate.
Definition: qrect.h:674

◆ setTopRight()

void QRectF::setTopRight ( const QPointF position)
inline

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 680 of file qrect.h.

680 { setRight(p.x()); setTop(p.y()); }
void setTop(qreal pos)
Sets the top edge of the rectangle to the given y coordinate.
Definition: qrect.h:674
void setRight(qreal pos)
Sets the right edge of the rectangle to the given x coordinate.
Definition: qrect.h:672

◆ setWidth()

void QRectF::setWidth ( qreal  width)
inline

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 784 of file qrect.h.

Referenced by _q_boundGeometryToSizeConstraints(), QPlainTextDocumentLayout::blockBoundingRect(), QTextDocumentLayoutPrivate::drawFrameDecoration(), QPlainTextEdit::paintEvent(), QTextControl::setExtraSelections(), and QDeclarativeRectFValueType::setWidth().

785 { this->w = aw; }
qreal w
Definition: qrect.h:608

◆ setX()

void QRectF::setX ( qreal  x)
inline

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 536 of file qrect.h.

536 { setLeft(pos); }
void setLeft(qreal pos)
Sets the left edge of the rectangle to the given x coordinate.
Definition: qrect.h:670

◆ setY()

void QRectF::setY ( qreal  y)
inline

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 537 of file qrect.h.

537 { setTop(pos); }
void setTop(qreal pos)
Sets the top edge of the rectangle to the given y coordinate.
Definition: qrect.h:674

◆ size()

QSizeF QRectF::size ( ) const
inline

Returns the size of the rectangle.

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

Definition at line 713 of file qrect.h.

Referenced by QGraphicsTextItemPrivate::_q_updateBoundingRect(), CapabilitiesToStateMask::canBlitterDrawPixmap(), QGridLayoutEngine::cellRect(), QBlitterPaintEnginePrivate::clipAndDrawPixmap(), QVGPixmapConvolutionFilter::draw(), QVGPixmapColorizeFilter::draw(), QVGPixmapDropShadowFilter::draw(), QVGPixmapBlurFilter::draw(), QDirectFBPaintEngine::drawImage(), QX11PaintEngine::drawImage(), QVGPaintEngine::drawImage(), QDirectFBPaintEngine::drawPixmap(), QWin32PrintEngine::drawPixmap(), QRasterPaintEngine::drawPixmap(), QVGPaintEngine::drawPixmapFragments(), drawTexture(), QPainter::drawTiledPixmap(), drawVGImage(), QBlitterPaintEngine::fillRect(), ShaderEffectItem::geometryChanged(), QDeclarativePathViewPrivate::itemGeometryChanged(), QDeclarativeBasePositionerPrivate::itemGeometryChanged(), QSvgTinyDocument::mapSourceToTarget(), QPainterPath::operator==(), QGraphicsItemEffectSourcePrivate::paddedEffectRect(), QStaticTextPrivate::paintText(), QGridLayoutEngine::setGeometries(), QGraphicsLayoutItem::setGeometry(), QGraphicsWidget::setGeometry(), QFontMetricsF::size(), QGraphicsSvgItemPrivate::updateDefaultSize(), QGraphicsWidgetPrivate::windowFrameMouseMoveEvent(), and QGraphicsWidget::~QGraphicsWidget().

714 { return QSizeF(w, h); }
qreal h
Definition: qrect.h:609
The QSizeF class defines the size of a two-dimensional object using floating point precision...
Definition: qsize.h:202
qreal w
Definition: qrect.h:608

◆ toAlignedRect()

QRect QRectF::toAlignedRect ( ) const

Returns a QRect based on the values of this rectangle that is the smallest possible integer rectangle that completely contains this rectangle.

Since
4.3
See also
toRect()

Definition at line 2817 of file qrect.cpp.

Referenced by QTextEditPrivate::_q_repaintContents(), QPlainTextEditPrivate::_q_repaintContents(), QFontMetrics::boundingRect(), QGLPathMaskGenerator::computeScreenRect(), QGLLineMaskGenerator::computeScreenRect(), QGLRectMaskGenerator::computeScreenRect(), convolute(), QPixmapBlurFilter::draw(), QPixmapColorizeFilter::draw(), QPainterPrivate::draw_helper(), QX11PaintEngine::drawEllipse(), QRasterPaintEngine::drawImage(), QGraphicsScenePrivate::drawItemHelper(), QRasterPaintEngine::drawPixmap(), QX11PaintEngine::drawRects(), QGraphicsItemPrivate::effectiveBoundingRect(), QRasterPaintEnginePrivate::isUnclipped(), QGraphicsViewPrivate::mapToViewRect(), QGraphicsItemEffectSourcePrivate::paddedEffectRect(), QWidgetEffectSourcePrivate::pixmap(), QGLPixmapDropShadowFilter::processGL(), QX11PixmapData::transformed(), QImage::transformed(), QGraphicsViewPrivate::updateRectF(), and QGraphicsViewPrivate::updateRegion().

2818 {
2819  int xmin = int(qFloor(xp));
2820  int xmax = int(qCeil(xp + w));
2821  int ymin = int(qFloor(yp));
2822  int ymax = int(qCeil(yp + h));
2823  return QRect(xmin, ymin, xmax - xmin, ymax - ymin);
2824 }
int qCeil(qreal v)
Definition: qmath.h:63
int qFloor(qreal v)
Definition: qmath.h:73
qreal xp
Definition: qrect.h:606
qreal h
Definition: qrect.h:609
qreal w
Definition: qrect.h:608
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
qreal yp
Definition: qrect.h:607

◆ top()

qreal QRectF::top ( ) const
inline

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

Equivalent to y().

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

Definition at line 526 of file qrect.h.

Referenced by QPlainTextEditPrivate::_q_adjustScrollbars(), _q_boundGeometryToSizeConstraints(), QPrintPreviewWidgetPrivate::_q_fit(), QGL2PEXVertexArray::addQuad(), QGL2PEXVertexArray::addRect(), addSelectedRegionsToPath(), QmlJSDebugger::QDeclarativeViewInspector::adjustToScreenBoundaries(), QTextControl::anchorPosition(), QRenderRule::borderClip(), QGraphicsSceneBspTree::climbTree(), QBlitterPaintEnginePrivate::clipAndDrawPixmap(), QGraphicsSceneBspTree::debug(), QTextDocumentLayoutPrivate::drawBlock(), QTextDocumentLayoutPrivate::drawBorder(), QOpenGLPaintEnginePrivate::drawFastRect(), QTextDocumentLayoutPrivate::drawFrame(), QTextDocumentLayoutPrivate::drawFrameDecoration(), QRasterPaintEngine::drawImage(), QOpenGLPaintEnginePrivate::drawImageAsPath(), QGL2PaintEngineEx::drawPixmap(), QGL2PaintEngineExPrivate::drawPixmapFragments(), QPaintEngineEx::drawRoundedRect(), QTextDocumentLayoutPrivate::drawTableCell(), QGL2PaintEngineEx::drawTexture(), drawTexture(), QOpenGLPaintEnginePrivate::drawTiledImageAsPath(), QWin32PrintEngine::drawTiledPixmap(), QOutlineMapper::endOutline(), QPlainTextEditPrivate::ensureVisible(), QGraphicsView::ensureVisible(), QScriptEdit::extraAreaPaintEvent(), QGL2PaintEngineExPrivate::fill(), QIntersectionFinder::hasIntersections(), QPlainTextEditControl::hitTest(), QTextDocumentLayoutPrivate::hitTest(), QGraphicsSceneBspTree::initialize(), QPainterPath::intersects(), QTextDocumentLayoutPrivate::layoutBlock(), needsPerspectiveClipping(), QMatrix4x4::ortho(), QTextEditPrivate::pageUpDown(), QPlainTextEditPrivate::pageUpDown(), QDeclarativeParticlesPainter::paint(), QPlainTextEdit::paintEvent(), printPage(), QDashStroker::processCurrentSubpath(), QGLPixmapDropShadowFilter::processGL(), qMapGradientToRect(), QRectF_intersects(), qSubImage(), qt_isect_curve_horizontal(), qt_isect_curve_vertical(), qt_painterpath_check_crossing(), qt_painterpath_isect_line_rect(), qt_scale_image_16bit(), qt_scale_image_32bit(), qt_transform_image(), QRasterizer::rasterize(), QGraphicsViewPrivate::recalculateContentSize(), QGraphicsScene::render(), QGraphicsView::render(), QGL2PaintEngineExPrivate::resetClipIfNeeded(), QmlJSDebugger::resizeRect(), QVGPaintEnginePrivate::roundedRectPath(), QGLEllipseMaskGenerator::screenRect(), QPainter::setClipRect(), QGraphicsAnchorLayoutPrivate::setItemsGeometries(), QTextBrowserPrivate::setSource(), QAlphaPaintEnginePrivate::toRect(), QTest::toString(), QPaintBufferPrivate::updateBoundingRect(), ShaderEffectItem::updateGeometry(), QSGGeometry::updateRectGeometry(), ShaderEffect::updateRenderTargets(), QSGGeometry::updateTexturedRectGeometry(), QGraphicsWidget::windowFrameSectionAt(), and QPicturePaintEngine::writeCmdLength().

526 { return yp; }
qreal yp
Definition: qrect.h:607

◆ topLeft()

QPointF QRectF::topLeft ( ) const
inline

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

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

Definition at line 539 of file qrect.h.

Referenced by QPainterPath::contains(), QVGPixmapConvolutionFilter::draw(), QVGPixmapColorizeFilter::draw(), QVGPixmapDropShadowFilter::draw(), QVGPixmapBlurFilter::draw(), QTextDocumentLayoutPrivate::drawBlock(), QTextDocumentLayoutPrivate::drawFrameDecoration(), QVGPaintEngine::drawImage(), QRasterPaintEngine::drawImage(), QTextDocumentLayoutPrivate::drawListItem(), QWin32PrintEngine::drawPixmap(), QRasterPaintEngine::drawPixmap(), QVGPaintEngine::drawPixmapFragments(), QVGPaintEngine::drawRects(), QRasterPaintEngine::drawRects(), QTextDocumentLayoutPrivate::drawTableCell(), QRasterPaintEngine::drawTiledPixmap(), QPainter::drawTiledPixmap(), drawVGImage(), QPlainTextEditPrivate::ensureVisible(), QRasterPaintEngine::fill(), fillBackground(), QDirectFBPaintEngine::fillRect(), QVGPaintEngine::fillRect(), QRasterPaintEngine::fillRect(), QIntersectionFinder::hasIntersections(), QTextDocumentLayoutPrivate::hitTest(), QOpenGLPaintEnginePrivate::isFastRect(), QGraphicsSceneIndexPrivate::itemCollidesWithPath(), QGraphicsView::mapFromScene(), QMatrix4x4::mapRect(), QGraphicsViewPrivate::mapToScene(), QLabel::paintEvent(), QGraphicsWidget::paintWindowFrame(), QGraphicsItemEffectSourcePrivate::pixmap(), qt_mapRect_non_normalizing(), QGLEllipseMaskGenerator::screenRect(), QGraphicsLayoutItem::setGeometry(), QGraphicsWidget::setGeometry(), QGraphicsProxyWidgetPrivate::updateProxyGeometryFromWidget(), and QGraphicsWidgetPrivate::windowFrameMouseMoveEvent().

539 { return QPointF(xp, yp); }
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
qreal xp
Definition: qrect.h:606
qreal yp
Definition: qrect.h:607

◆ topRight()

QPointF QRectF::topRight ( ) const
inline

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

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

Definition at line 541 of file qrect.h.

Referenced by QPainterPath::contains(), QRasterPaintEngine::drawImage(), QVGPaintEngine::drawRects(), QRasterPaintEngine::drawRects(), QRasterPaintEngine::drawTiledPixmap(), QRasterPaintEngine::fill(), QVGPaintEngine::fillRect(), QRasterPaintEngine::fillRect(), QGraphicsView::mapFromScene(), QMatrix4x4::mapRect(), and QGraphicsViewPrivate::mapToScene().

541 { return QPointF(xp+w, yp); }
The QPointF class defines a point in the plane using floating point precision.
Definition: qpoint.h:214
qreal xp
Definition: qrect.h:606
qreal w
Definition: qrect.h:608
qreal yp
Definition: qrect.h:607

◆ toRect()

QRect QRectF::toRect ( ) const
inline

Returns a QRect based on the values of this rectangle.

Note that the coordinates in the returned rectangle are rounded to the nearest integer.

See also
QRectF(), toAlignedRect()

Definition at line 845 of file qrect.h.

Referenced by QTextEditPrivate::_q_ensureVisible(), QDirectFbBlitter::alphaFillRect(), QDirectFBPaintEnginePrivate::blit(), QVGPaintEngine::clip(), QOpenGLPaintEngine::clip(), QPainter::clipRegion(), clipTransformIsSimple(), QVGPixmapConvolutionFilter::draw(), QVGPixmapColorizeFilter::draw(), QVGPixmapDropShadowFilter::draw(), QVGPixmapBlurFilter::draw(), QPixmapConvolutionFilter::draw(), QTextDocumentLayoutPrivate::drawBorder(), QPSPrintEngine::drawImage(), QPdfEngine::drawImage(), QVGPaintEngine::drawImage(), QRasterPaintEngine::drawImage(), QGraphicsScenePrivate::drawItemHelper(), QPSPrintEngine::drawPixmap(), QWin32PrintEngine::drawPixmap(), QPdfEngine::drawPixmap(), QVGPaintEngine::drawPixmapFragments(), QDirectFbBlitter::drawPixmapOpacity(), QDirectFBPaintEnginePrivate::drawTiledPixmap(), QRasterPaintEngine::drawTiledPixmap(), drawVGImage(), QBlitterPaintEnginePrivate::fillRect(), QSystemTrayIconPrivate::geometry_sys(), QGraphicsWidget::initStyleOption(), QGraphicsItemPrivate::initStyleOption(), QPlainTextEdit::inputMethodQuery(), QTextEdit::inputMethodQuery(), QDeclarativePaintedItem::paint(), QDeclarativeText::paint(), QLabel::paintEvent(), QAccessibleTextEdit::rect(), QAccessibleDial::rect(), QGraphicsScene::render(), QGraphicsView::render(), QWidgetPrivate::screenGeometry(), QPainter::setClipRect(), QmlJSDebugger::SubcomponentMaskLayerItem::setCurrentItem(), QXRenderTessellator::tessellate(), and QDeclarativeTextEdit::updateImgCache().

846 {
847  return QRect(qRound(xp), qRound(yp), qRound(w), qRound(h));
848 }
qreal xp
Definition: qrect.h:606
qreal h
Definition: qrect.h:609
qreal w
Definition: qrect.h:608
The QRect class defines a rectangle in the plane using integer precision.
Definition: qrect.h:58
qreal yp
Definition: qrect.h:607
Q_DECL_CONSTEXPR int qRound(qreal d)
Definition: qglobal.h:1203

◆ translate() [1/2]

void QRectF::translate ( qreal  dx,
qreal  dy 
)
inline

◆ translate() [2/2]

void QRectF::translate ( const QPointF offset)
inline

Moves the rectangle {offset}.

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

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

Definition at line 722 of file qrect.h.

723 {
724  xp += p.x();
725  yp += p.y();
726 }
qreal xp
Definition: qrect.h:606
qreal yp
Definition: qrect.h:607

◆ translated() [1/2]

QRectF QRectF::translated ( qreal  dx,
qreal  dy 
) const
inline

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 740 of file qrect.h.

Referenced by QDeclarativeTextEdit::boundingRect(), QPixmapDropShadowFilter::boundingRectFor(), QPixmapConvolutionFilter::draw(), QPixmapBlurFilter::draw(), QTextLayout::draw(), QTextDocumentLayoutPrivate::drawListItem(), QRasterPaintEngine::drawPixmap(), QGraphicsScenePrivate::drawSubtreeRecursive(), QPlainTextEditPrivate::ensureVisible(), QScriptEdit::extraAreaPaintEvent(), QRasterPaintEngine::fillRect(), QGraphicsTextItem::inputMethodQuery(), QGraphicsProxyWidgetPrivate::inputMethodQueryHelper(), QGraphicsSceneIndexRectIntersector::intersect(), QGraphicsSceneIndexPointIntersector::intersect(), QGraphicsSceneIndexPathIntersector::intersect(), QGraphicsItem::mapFromParent(), QGraphicsItem::mapFromScene(), QTransform::mapRect(), QMatrix4x4::mapRect(), QGraphicsItem::mapRectFromParent(), QGraphicsItem::mapRectFromScene(), QGraphicsItem::mapRectToParent(), QGraphicsItem::mapRectToScene(), QGraphicsItem::mapToParent(), QGraphicsItem::mapToScene(), QGraphicsViewPrivate::mapToViewRect(), QLabel::paintEvent(), QPlainTextEdit::paintEvent(), QGraphicsScenePrivate::processDirtyItemsRecursive(), QGLPixmapBlurFilter::processGL(), qSubImage(), and QGraphicsWidgetPrivate::windowFrameHoverMoveEvent().

741 { return QRectF(xp + dx, yp + dy, w, h); }
qreal xp
Definition: qrect.h:606
qreal h
Definition: qrect.h:609
qreal w
Definition: qrect.h:608
QRectF()
Constructs a null rectangle.
Definition: qrect.h:514
qreal yp
Definition: qrect.h:607

◆ translated() [2/2]

QRectF QRectF::translated ( const QPointF offset) const
inline

Returns a copy of the rectangle that is translated {offset}.

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

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

Definition at line 743 of file qrect.h.

744 { return QRectF(xp + p.x(), yp + p.y(), w, h); }
qreal xp
Definition: qrect.h:606
qreal h
Definition: qrect.h:609
qreal w
Definition: qrect.h:608
QRectF()
Constructs a null rectangle.
Definition: qrect.h:514
qreal yp
Definition: qrect.h:607

◆ unite()

QRectF QRectF::unite ( const QRectF rectangle) const
inline

Use united(rectangle) instead.

Definition at line 823 of file qrect.h.

Referenced by united().

824 {
825  return *this | r;
826 }

◆ united()

QRectF QRectF::united ( const QRectF rectangle) const
inline

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

Since
4.2
qrect-unite.png
See also
intersected()

Definition at line 828 of file qrect.h.

Referenced by QPixmapDropShadowFilter::boundingRectFor(), QTextBrowserPrivate::setSource(), and QDeclarativeTextPrivate::setupTextLayout().

829 {
830  return unite(r);
831 }
QRectF unite(const QRectF &r) const
Use united(rectangle) instead.
Definition: qrect.h:823

◆ width()

qreal QRectF::width ( ) const
inline

Returns the width of the rectangle.

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

Definition at line 707 of file qrect.h.

Referenced by _q_adjustRect(), _q_boundGeometryToSizeConstraints(), QPrintPreviewWidgetPrivate::_q_fit(), QPainterPath::addEllipse(), QGL2PEXVertexArray::addPath(), QPathSegments::addPath(), QPainterPath::addRect(), QPainterPath::addRoundedRect(), QPainterPath::addRoundRect(), QPainterPath::arcTo(), QPlainTextDocumentLayout::blockBoundingRect(), QDeclarativeItemPrivate::computeTransformOrigin(), QPathClipper::contains(), QOpenGLPaintEnginePrivate::copyDrawable(), QPainter::PixmapFragment::create(), createRectNode(), QTriangulatingStroker::cubicTo(), QGraphicsSceneBspTree::debug(), QAlphaPaintEnginePrivate::drawAlphaImage(), QPainter::drawArc(), QTextDocumentLayoutPrivate::drawBlock(), QPainter::drawChord(), QStyleHelper::drawDial(), QCoreGraphicsPaintEngine::drawEllipse(), QVGPaintEngine::drawEllipse(), QRasterPaintEngine::drawEllipse(), QPainter::drawEllipse(), QTextDocumentLayoutPrivate::drawFrameDecoration(), QPdfEngine::drawImage(), QCoreGraphicsPaintEngine::drawImage(), QX11PaintEngine::drawImage(), QVGPaintEngine::drawImage(), QSvgPaintEngine::drawImage(), QPaintEngine::drawImage(), QRasterPaintEngine::drawImage(), QPainter::drawImage(), QOpenGLPaintEnginePrivate::drawImageAsPath(), QPSPrintEngine::drawImageInternal(), drawImageTiled(), QGraphicsScenePrivate::drawItemHelper(), QTextDocumentLayoutPrivate::drawListItem(), QGLEllipseMaskGenerator::drawMask(), QPainter::drawPath(), QPainter::drawPie(), QWin32PrintEngine::drawPixmap(), QPdfEngine::drawPixmap(), QCoreGraphicsPaintEngine::drawPixmap(), QX11PaintEngine::drawPixmap(), QPainter::drawPixmap(), QVGPaintEngine::drawPixmapFragments(), QVGPaintEngine::drawRects(), QPaintEngine::drawRects(), QPaintEngineEx::drawRects(), QRasterPaintEngine::drawRects(), QPdfBaseEngine::drawRects(), QPainter::drawRects(), QPaintEngineEx::drawRoundedRect(), QPainter::drawRoundedRect(), QTextDocumentLayoutPrivate::drawTableCell(), QPainter::drawText(), QOpenGLPaintEngine::drawTextureRect(), QPSPrintEngine::drawTiledPixmap(), QWin32PrintEngine::drawTiledPixmap(), QCoreGraphicsPaintEngine::drawTiledPixmap(), QX11PaintEngine::drawTiledPixmap(), QOpenGLPaintEngine::drawTiledPixmap(), QPaintEngine::drawTiledPixmap(), QRasterPaintEngine::drawTiledPixmap(), QPaintEngineEx::drawTiledPixmap(), QPainter::drawTiledPixmap(), drawVGImage(), QPdfEnginePrivate::embedFont(), QOutlineMapper::endOutline(), QEmulationPaintEngine::fill(), QRasterPaintEngine::fill(), QEmulationPaintEngine::fillBGRect(), QVGPaintEngine::fillRect(), QPaintEngineEx::fillRect(), QBlitterPaintEnginePrivate::fillRect(), QRasterPaintEngine::fillRect(), QGridLayoutEngine::fillRowData(), QGraphicsView::fitInView(), QDeclarativeCompiler::genLiteralAssignment(), QDeclarativePaintedItem::geometryChanged(), QDeclarativeItem::geometryChanged(), QDeclarativeText::geometryChanged(), QDeclarativeFlickable::geometryChanged(), QDeclarativeTextInput::geometryChanged(), QDeclarativeListView::geometryChanged(), QDeclarativeTextEdit::geometryChanged(), QGraphicsSceneBspTree::initialize(), QPathClipper::intersect(), QDeclarativeLoaderPrivate::itemGeometryChanged(), QDeclarativeContents::itemGeometryChanged(), QDeclarativeAnchorsPrivate::itemGeometryChanged(), QDeclarativeGridViewPrivate::itemGeometryChanged(), QDeclarativeListViewPrivate::itemGeometryChanged(), QLabelPrivate::layoutRect(), QSvgIOHandlerPrivate::load(), QMacPixmapData::macCreatePixels(), QMatrix::mapRect(), QTransform::mapRect(), QMatrix4x4::mapRect(), QSvgTinyDocument::mapSourceToTarget(), QPaintBuffer::metric(), QmlJSDebugger::ZoomTool::mouseReleaseEvent(), operator<<(), QDeclarativeParticlesPainter::paint(), QPlainTextEdit::paintEvent(), printPage(), QDashedStrokeProcessor::process(), QGLPixmapBlurFilter::processGL(), qDrawBorder(), QPolygonF::QPolygonF(), QRectF_intersects(), qt_curves_for_arc(), qt_find_ellipse_coords(), qt_format_text(), qt_graphicsItem_highlightSelected(), qt_isect_curve_horizontal(), qt_isect_curve_vertical(), qt_mac_compose_rect(), qt_mac_create_imagemask(), qt_painterpath_isect_curve(), qt_scale_image_16bit(), qt_scale_image_32bit(), qt_scale_image_argb24_on_rgb16(), qt_scale_image_argb32_on_argb32(), qt_scale_image_argb32_on_rgb16(), qt_scale_image_rgb16_on_rgb16(), qt_scale_image_rgb32_on_rgb32(), QGraphicsViewPrivate::recalculateContentSize(), QGraphicsScene::render(), QGraphicsView::render(), QPaintEngineExPrivate::replayClipOperations(), QVGPaintEnginePrivate::roundedRectPath(), scaleRect(), QPainter::setClipPath(), QPainter::setClipRect(), QDeclarativeLayoutItem::setGeometry(), QX11WindowSurface::setGeometry(), setPenAndDrawBackground(), QDeclarativeTextPrivate::setupTextLayout(), QDeclarativeRectFValueType::setY(), shift(), stretchGradientToUserSpace(), QEmulationPaintEngine::stroke(), toRect_normalized(), QTest::toString(), glyph_metrics_t::transformed(), ShaderEffectItem::updateEffectState(), ShaderEffectItem::updateGeometry(), QGraphicsScene::width(), and QPicturePaintEngine::writeCmdLength().

708 { return w; }
qreal w
Definition: qrect.h:608

◆ x()

qreal QRectF::x ( ) const
inline

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

Equivalent to left().

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

Definition at line 664 of file qrect.h.

Referenced by QPainterPath::addEllipse(), QPainterPath::addRect(), QPainterPath::addRoundedRect(), QPainterPath::addRoundRect(), QPainterPath::arcTo(), QRenderRule::borderClip(), QPainter::boundingRect(), QGridLayoutEngine::cellRect(), QPathClipper::contains(), QPainter::PixmapFragment::create(), QAlphaPaintEnginePrivate::drawAlphaImage(), QPainter::drawArc(), QPainter::drawChord(), QCoreGraphicsPaintEngine::drawEllipse(), QVGPaintEngine::drawEllipse(), QRasterPaintEngine::drawEllipse(), QPainter::drawEllipse(), QPdfEngine::drawImage(), QCoreGraphicsPaintEngine::drawImage(), QX11PaintEngine::drawImage(), QVGPaintEngine::drawImage(), QSvgPaintEngine::drawImage(), QPaintEngine::drawImage(), QRasterPaintEngine::drawImage(), QPainter::drawImage(), QPSPrintEngine::drawImageInternal(), drawImageTiled(), QPainter::drawPath(), QPainter::drawPie(), QPdfEngine::drawPixmap(), QCoreGraphicsPaintEngine::drawPixmap(), QX11PaintEngine::drawPixmap(), QPainter::drawPixmap(), QVGPaintEngine::drawRects(), QPaintEngine::drawRects(), QPaintEngineEx::drawRects(), QPdfBaseEngine::drawRects(), QPainter::drawRoundedRect(), QPainter::drawText(), drawTexture(), QOpenGLPaintEngine::drawTextureRect(), QPSPrintEngine::drawTiledPixmap(), QCoreGraphicsPaintEngine::drawTiledPixmap(), QX11PaintEngine::drawTiledPixmap(), QVGPaintEngine::drawTiledPixmap(), QPaintEngine::drawTiledPixmap(), QRasterPaintEngine::drawTiledPixmap(), QPaintEngineEx::drawTiledPixmap(), QPainter::drawTiledPixmap(), drawVGImage(), QPdfEnginePrivate::embedFont(), QOutlineMapper::endOutline(), QEmulationPaintEngine::fill(), QEmulationPaintEngine::fillBGRect(), QBlitterPaintEngine::fillRect(), QVGPaintEngine::fillRect(), QPaintEngineEx::fillRect(), QBlitterPaintEnginePrivate::fillRect(), QGridLayoutEngine::fillRowData(), QDeclarativeCompiler::genLiteralAssignment(), QDeclarativeMouseArea::geometryChanged(), QPathClipper::intersect(), QDeclarativeContents::itemGeometryChanged(), QDeclarativeAnchorsPrivate::itemGeometryChanged(), QDeclarativeFlickablePrivate::itemGeometryChanged(), QLabelPrivate::layoutRect(), QMatrix::mapRect(), QTransform::mapRect(), QMatrix4x4::mapRect(), QSvgTinyDocument::mapSourceToTarget(), QDeclarativeTextEdit::moveCursorDelegate(), operator<<(), QDeclarativeText::paint(), QLabel::paintEvent(), QGLPixmapBlurFilter::processGL(), qDrawBorder(), QPolygonF::QPolygonF(), qt_curves_for_arc(), qt_format_text(), qt_mac_compose_rect(), qt_mac_create_imagemask(), qt_scale_image_argb24_on_rgb16(), qt_scale_image_argb32_on_argb32(), qt_scale_image_argb32_on_rgb16(), qt_scale_image_rgb16_on_rgb16(), qt_scale_image_rgb32_on_rgb32(), qt_true_matrix(), QPaintEngineExPrivate::replayClipOperations(), scaleRect(), QPainter::setClipPath(), QPainter::setClipRect(), QGridLayoutEngine::setGeometries(), QDeclarativeLayoutItem::setGeometry(), QX11WindowSurface::setGeometry(), setPenAndDrawBackground(), QDeclarativeTextPrivate::setupTextLayout(), QDeclarativeRectFValueType::setValue(), stretchGradientToUserSpace(), QEmulationPaintEngine::stroke(), toAlignedRect_positive(), toNormalizedFillRect(), toRect_normalized(), and ShaderEffectItem::updateEffectState().

665 { return xp; }
qreal xp
Definition: qrect.h:606

◆ y()

qreal QRectF::y ( ) const
inline

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

Equivalent to top().

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

Definition at line 667 of file qrect.h.

Referenced by QPainterPath::addEllipse(), QPainterPath::addRect(), QPainterPath::addRoundedRect(), QPainterPath::addRoundRect(), QPainterPath::arcTo(), QRenderRule::borderClip(), QPainter::boundingRect(), QGridLayoutEngine::cellRect(), QPathClipper::contains(), QPainter::PixmapFragment::create(), QTextLayout::draw(), QAlphaPaintEnginePrivate::drawAlphaImage(), QPainter::drawArc(), QTextDocumentLayoutPrivate::drawBlock(), QPainter::drawChord(), QCoreGraphicsPaintEngine::drawEllipse(), QVGPaintEngine::drawEllipse(), QRasterPaintEngine::drawEllipse(), QPainter::drawEllipse(), QPdfEngine::drawImage(), QCoreGraphicsPaintEngine::drawImage(), QX11PaintEngine::drawImage(), QVGPaintEngine::drawImage(), QSvgPaintEngine::drawImage(), QPaintEngine::drawImage(), QRasterPaintEngine::drawImage(), QPainter::drawImage(), QPSPrintEngine::drawImageInternal(), drawImageTiled(), QPainter::drawPath(), QPainter::drawPie(), QPdfEngine::drawPixmap(), QCoreGraphicsPaintEngine::drawPixmap(), QX11PaintEngine::drawPixmap(), QPainter::drawPixmap(), QVGPaintEngine::drawRects(), QPaintEngine::drawRects(), QPaintEngineEx::drawRects(), QPdfBaseEngine::drawRects(), QPainter::drawRects(), QPainter::drawRoundedRect(), QPainter::drawText(), QOpenGLPaintEngine::drawTextureRect(), QPSPrintEngine::drawTiledPixmap(), QCoreGraphicsPaintEngine::drawTiledPixmap(), QX11PaintEngine::drawTiledPixmap(), QVGPaintEngine::drawTiledPixmap(), QPaintEngine::drawTiledPixmap(), QRasterPaintEngine::drawTiledPixmap(), QPaintEngineEx::drawTiledPixmap(), QPainter::drawTiledPixmap(), drawVGImage(), QPdfEnginePrivate::embedFont(), QOutlineMapper::endOutline(), QEmulationPaintEngine::fill(), QEmulationPaintEngine::fillBGRect(), QBlitterPaintEngine::fillRect(), QVGPaintEngine::fillRect(), QPaintEngineEx::fillRect(), QBlitterPaintEnginePrivate::fillRect(), QGridLayoutEngine::fillRowData(), QDeclarativeCompiler::genLiteralAssignment(), QDeclarativeMouseArea::geometryChanged(), QPathClipper::intersect(), QDeclarativeContents::itemGeometryChanged(), QDeclarativeAnchorsPrivate::itemGeometryChanged(), QDeclarativeFlickablePrivate::itemGeometryChanged(), QLabelPrivate::layoutRect(), QMatrix::mapRect(), QTransform::mapRect(), QMatrix4x4::mapRect(), QSvgTinyDocument::mapSourceToTarget(), QDeclarativeTextEdit::moveCursorDelegate(), operator<<(), QDeclarativeText::paint(), QLabel::paintEvent(), qDrawBorder(), QPolygonF::QPolygonF(), qt_curves_for_arc(), qt_format_text(), qt_mac_compose_rect(), qt_mac_create_imagemask(), qt_painterpath_isect_curve(), qt_scale_image_argb24_on_rgb16(), qt_scale_image_argb32_on_argb32(), qt_scale_image_argb32_on_rgb16(), qt_scale_image_rgb16_on_rgb16(), qt_scale_image_rgb32_on_rgb32(), qt_true_matrix(), QPaintEngineExPrivate::replayClipOperations(), scaleRect(), QPainter::setClipPath(), QPainter::setClipRect(), QGridLayoutEngine::setGeometries(), QDeclarativeLayoutItem::setGeometry(), QX11WindowSurface::setGeometry(), setPenAndDrawBackground(), QDeclarativeTextPrivate::setupTextLayout(), QDeclarativeRectFValueType::setValue(), stretchGradientToUserSpace(), QEmulationPaintEngine::stroke(), toAlignedRect_positive(), toNormalizedFillRect(), toRect_normalized(), and ShaderEffectItem::updateEffectState().

668 { return yp; }
qreal yp
Definition: qrect.h:607

Friends and Related Functions

◆ operator!=

bool operator!= ( const QRectF r1,
const QRectF r2 
)
friend

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

Definition at line 839 of file qrect.h.

840 {
841  return !qFuzzyCompare(r1.xp, r2.xp) || !qFuzzyCompare(r1.yp, r2.yp)
842  || !qFuzzyCompare(r1.w, r2.w) || !qFuzzyCompare(r1.h, r2.h);
843 }
qreal xp
Definition: qrect.h:606
static Q_DECL_CONSTEXPR bool qFuzzyCompare(double p1, double p2)
Definition: qglobal.h:2030
qreal h
Definition: qrect.h:609
qreal w
Definition: qrect.h:608
qreal yp
Definition: qrect.h:607

◆ operator<<()

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

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

See also
{Serializing Qt Data Types}

Definition at line 2879 of file qrect.cpp.

Referenced by toRect().

2880 {
2881  s << double(r.x()) << double(r.y()) << double(r.width()) << double(r.height());
2882  return s;
2883 }

◆ operator==

bool operator== ( const QRectF r1,
const QRectF r2 
)
friend

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

Definition at line 833 of file qrect.h.

834 {
835  return qFuzzyCompare(r1.xp, r2.xp) && qFuzzyCompare(r1.yp, r2.yp)
836  && qFuzzyCompare(r1.w, r2.w) && qFuzzyCompare(r1.h, r2.h);
837 }
qreal xp
Definition: qrect.h:606
static Q_DECL_CONSTEXPR bool qFuzzyCompare(double p1, double p2)
Definition: qglobal.h:2030
qreal h
Definition: qrect.h:609
qreal w
Definition: qrect.h:608
qreal yp
Definition: qrect.h:607

◆ operator>>()

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

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

See also
{Serializing Qt Data Types}

Definition at line 2899 of file qrect.cpp.

2900 {
2901  double x, y, w, h;
2902  s >> x;
2903  s >> y;
2904  s >> w;
2905  s >> h;
2906  r.setRect(qreal(x), qreal(y), qreal(w), qreal(h));
2907  return s;
2908 }
qreal y() const
Returns the y-coordinate of the rectangle&#39;s top edge.
Definition: qrect.h:667
double qreal
Definition: qglobal.h:1193
qreal h
Definition: qrect.h:609
qreal w
Definition: qrect.h:608
qreal x() const
Returns the x-coordinate of the rectangle&#39;s left edge.
Definition: qrect.h:664

Properties

◆ h

qreal QRectF::h
private

◆ w

qreal QRectF::w
private

◆ xp

qreal QRectF::xp
private

◆ yp

qreal QRectF::yp
private

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