1 /****************************************************************************
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** All rights reserved.
5 ** Contact: http://www.qt-project.org/
7 ** This file is part of the QtCore module of the Qt Toolkit.
9 ** $QT_BEGIN_LICENSE:LGPL$
10 ** GNU Lesser General Public License Usage
11 ** This file may be used under the terms of the GNU Lesser General Public
12 ** License version 2.1 as published by the Free Software Foundation and
13 ** appearing in the file LICENSE.LGPL included in the packaging of this
14 ** file. Please review the following information to ensure the GNU Lesser
15 ** General Public License version 2.1 requirements will be met:
16 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
18 ** In addition, as a special exception, Nokia gives you certain additional
19 ** rights. These rights are described in the Nokia Qt LGPL Exception
20 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
22 ** GNU General Public License Usage
23 ** Alternatively, this file may be used under the terms of the GNU General
24 ** Public License version 3.0 as published by the Free Software Foundation
25 ** and appearing in the file LICENSE.GPL included in the packaging of this
26 ** file. Please review the following information to ensure the GNU General
27 ** Public License version 3.0 requirements will be met:
28 ** http://www.gnu.org/copyleft/gpl.html.
31 ** Alternatively, this file may be used in accordance with the terms and
32 ** conditions contained in a signed written agreement between you and Nokia.
40 ****************************************************************************/
43 #include "qdatastream.h"
55 \brief The QRect class defines a rectangle in the plane using
58 A rectangle is normally expressed as an upper-left corner and a
59 size. The size (width and height) of a QRect is always equivalent
60 to the mathematical rectangle that forms the basis for its
63 A QRect can be constructed with a set of left, top, width and
64 height integers, or from a QPoint and a QSize. The following code
65 creates two identical rectangles.
67 \snippet doc/src/snippets/code/src_corelib_tools_qrect.cpp 0
69 There is a third constructor that creates a QRect using the
70 top-left and bottom-right coordinates, but we recommend that you
71 avoid using it. The rationale is that for historical reasons the
72 values returned by the bottom() and right() functions deviate from
73 the true bottom-right corner of the rectangle.
75 The QRect class provides a collection of functions that return the
76 various rectangle coordinates, and enable manipulation of
77 these. QRect also provide functions to move the rectangle relative
78 to the various coordinates. In addition there is a moveTo()
79 function that moves the rectangle, leaving its top left corner at
80 the given coordinates. Alternatively, the translate() function
81 moves the rectangle the given offset relative to the current
82 position, and the translated() function returns a translated copy
85 The size() function returns the rectange's dimensions as a
86 QSize. The dimensions can also be retrieved separately using the
87 width() and height() functions. To manipulate the dimensions use
88 the setSize(), setWidth() or setHeight() functions. Alternatively,
89 the size can be changed by applying either of the functions
90 setting the rectangle coordinates, for example, setBottom() or
93 The contains() function tells whether a given point is inside the
94 rectangle or not, and the intersects() function returns true if
95 this rectangle intersects with a given rectangle. The QRect class
96 also provides the intersected() function which returns the
97 intersection rectangle, and the united() function which returns the
98 rectangle that encloses the given rectangle and this:
102 \o \inlineimage qrect-intersect.png
103 \o \inlineimage qrect-unite.png
109 The isEmpty() function returns true if left() > right() or top() >
110 bottom(). Note that an empty rectangle is not valid: The isValid()
111 function returns true if left() <= right() \e and top() <=
112 bottom(). A null rectangle (isNull() == true) on the other hand,
113 has both width and height set to 0.
115 Note that due to the way QRect and QRectF are defined, an
116 empty QRect is defined in essentially the same way as QRectF.
118 Finally, QRect objects can be streamed as well as compared.
124 When using an \l {QPainter::Antialiasing}{anti-aliased} painter,
125 the boundary line of a QRect will be rendered symmetrically on
126 both sides of the mathematical rectangle's boundary line. But when
127 using an aliased painter (the default) other rules apply.
129 Then, when rendering with a one pixel wide pen the QRect's boundary
130 line will be rendered to the right and below the mathematical
131 rectangle's boundary line.
133 When rendering with a two pixels wide pen the boundary line will
134 be split in the middle by the mathematical rectangle. This will be
135 the case whenever the pen is set to an even number of pixels,
136 while rendering with a pen with an odd number of pixels, the spare
137 pixel will be rendered to the right and below the mathematical
138 rectangle as in the one pixel case.
142 \o \inlineimage qrect-diagram-zero.png
143 \o \inlineimage qrect-diagram-one.png
145 \o Logical representation
146 \o One pixel wide pen
148 \o \inlineimage qrect-diagram-two.png
149 \o \inlineimage qrect-diagram-three.png
151 \o Two pixel wide pen
152 \o Three pixel wide pen
155 \section1 Coordinates
157 The QRect class provides a collection of functions that return the
158 various rectangle coordinates, and enable manipulation of
159 these. QRect also provide functions to move the rectangle relative
160 to the various coordinates.
162 For example the left(), setLeft() and moveLeft() functions as an
163 example: left() returns the x-coordinate of the rectangle's left
164 edge, setLeft() sets the left edge of the rectangle to the given x
165 coordinate (it may change the width, but will never change the
166 rectangle's right edge) and moveLeft() moves the entire rectangle
167 horizontally, leaving the rectangle's left edge at the given x
168 coordinate and its size unchanged.
170 \image qrect-coordinates.png
172 Note that for historical reasons the values returned by the
173 bottom() and right() functions deviate from the true bottom-right
174 corner of the rectangle: The right() function returns \e { left()
175 + width() - 1} and the bottom() function returns \e {top() +
176 height() - 1}. The same is the case for the point returned by the
177 bottomRight() convenience function. In addition, the x and y
178 coordinate of the topRight() and bottomLeft() functions,
179 respectively, contain the same deviation from the true right and
182 We recommend that you use x() + width() and y() + height() to find
183 the true bottom-right corner, and avoid right() and
184 bottom(). Another solution is to use QRectF: The QRectF class
185 defines a rectangle in the plane using floating point accuracy for
186 coordinates, and the QRectF::right() and QRectF::bottom()
187 functions \e do return the right and bottom coordinates.
189 It is also possible to add offsets to this rectangle's coordinates
190 using the adjust() function, as well as retrieve a new rectangle
191 based on adjustments of the original one using the adjusted()
192 function. If either of the width and height is negative, use the
193 normalized() function to retrieve a rectangle where the corners
196 In addition, QRect provides the getCoords() function which extracts
197 the position of the rectangle's top-left and bottom-right corner,
198 and the getRect() function which extracts the rectangle's top-left
199 corner, width and height. Use the setCoords() and setRect()
200 function to manipulate the rectangle's coordinates and dimensions
206 /*****************************************************************************
207 QRect member functions
208 *****************************************************************************/
213 Constructs a null rectangle.
219 \fn QRect::QRect(const QPoint &topLeft, const QPoint &bottomRight)
221 Constructs a rectangle with the given \a topLeft and \a bottomRight corners.
223 \sa setTopLeft(), setBottomRight()
228 \fn QRect::QRect(const QPoint &topLeft, const QSize &size)
230 Constructs a rectangle with the given \a topLeft corner and the
233 \sa setTopLeft(), setSize()
238 \fn QRect::QRect(int x, int y, int width, int height)
240 Constructs a rectangle with (\a x, \a y) as its top-left corner
241 and the given \a width and \a height.
248 \fn bool QRect::isNull() const
250 Returns true if the rectangle is a null rectangle, otherwise
253 A null rectangle has both the width and the height set to 0 (i.e.,
254 right() == left() - 1 and bottom() == top() - 1). A null rectangle
255 is also empty, and hence is not valid.
257 \sa isEmpty(), isValid()
261 \fn bool QRect::isEmpty() const
263 Returns true if the rectangle is empty, otherwise returns false.
265 An empty rectangle has a left() > right() or top() > bottom(). An
266 empty rectangle is not valid (i.e., isEmpty() == !isValid()).
268 Use the normalized() function to retrieve a rectangle where the
271 \sa isNull(), isValid(), normalized()
275 \fn bool QRect::isValid() const
277 Returns true if the rectangle is valid, otherwise returns false.
279 A valid rectangle has a left() < right() and top() <
280 bottom(). Note that non-trivial operations like intersections are
281 not defined for invalid rectangles. A valid rectangle is not empty
282 (i.e., isValid() == !isEmpty()).
284 \sa isNull(), isEmpty(), normalized()
289 Returns a normalized rectangle; i.e., a rectangle that has a
290 non-negative width and height.
292 If width() < 0 the function swaps the left and right corners, and
293 it swaps the top and bottom corners if height() < 0.
295 \sa isValid(), isEmpty()
298 QRect QRect::normalized() const
301 if (x2 < x1 - 1) { // swap bad x values
308 if (y2 < y1 - 1) { // swap bad y values
320 \fn int QRect::left() const
322 Returns the x-coordinate of the rectangle's left edge. Equivalent
325 \sa setLeft(), topLeft(), bottomLeft()
329 \fn int QRect::top() const
331 Returns the y-coordinate of the rectangle's top edge.
334 \sa setTop(), topLeft(), topRight()
338 \fn int QRect::right() const
340 Returns the x-coordinate of the rectangle's right edge.
342 Note that for historical reasons this function returns left() +
343 width() - 1; use x() + width() to retrieve the true x-coordinate.
345 \sa setRight(), topRight(), bottomRight()
349 \fn int QRect::bottom() const
351 Returns the y-coordinate of the rectangle's bottom edge.
353 Note that for historical reasons this function returns top() +
354 height() - 1; use y() + height() to retrieve the true y-coordinate.
356 \sa setBottom(), bottomLeft(), bottomRight()
360 \fn int QRect::x() const
362 Returns the x-coordinate of the rectangle's left edge. Equivalent to left().
364 \sa setX(), y(), topLeft()
368 \fn int QRect::y() const
370 Returns the y-coordinate of the rectangle's top edge. Equivalent to top().
372 \sa setY(), x(), topLeft()
376 \fn void QRect::setLeft(int x)
378 Sets the left edge of the rectangle to the given \a x
379 coordinate. May change the width, but will never change the right
380 edge of the rectangle.
382 Equivalent to setX().
384 \sa left(), moveLeft()
388 \fn void QRect::setTop(int y)
390 Sets the top edge of the rectangle to the given \a y
391 coordinate. May change the height, but will never change the
392 bottom edge of the rectangle.
394 Equivalent to setY().
400 \fn void QRect::setRight(int x)
402 Sets the right edge of the rectangle to the given \a x
403 coordinate. May change the width, but will never change the left
404 edge of the rectangle.
406 \sa right(), moveRight()
410 \fn void QRect::setBottom(int y)
412 Sets the bottom edge of the rectangle to the given \a y
413 coordinate. May change the height, but will never change the top
414 edge of the rectangle.
416 \sa bottom(), moveBottom(),
420 \fn void QRect::setX(int x)
422 Sets the left edge of the rectangle to the given \a x
423 coordinate. May change the width, but will never change the right
424 edge of the rectangle.
426 Equivalent to setLeft().
428 \sa x(), setY(), setTopLeft()
432 \fn void QRect::setY(int y)
434 Sets the top edge of the rectangle to the given \a y
435 coordinate. May change the height, but will never change the
436 bottom edge of the rectangle.
438 Equivalent to setTop().
440 \sa y(), setX(), setTopLeft()
444 \fn void QRect::setTopLeft(const QPoint &position)
446 Set the top-left corner of the rectangle to the given \a
447 position. May change the size, but will never change the
448 bottom-right corner of the rectangle.
450 \sa topLeft(), moveTopLeft()
454 \fn void QRect::setBottomRight(const QPoint &position)
456 Set the bottom-right corner of the rectangle to the given \a
457 position. May change the size, but will never change the
458 top-left corner of the rectangle.
460 \sa bottomRight(), moveBottomRight()
464 \fn void QRect::setTopRight(const QPoint &position)
466 Set the top-right corner of the rectangle to the given \a
467 position. May change the size, but will never change the
468 bottom-left corner of the rectangle.
470 \sa topRight(), moveTopRight()
474 \fn void QRect::setBottomLeft(const QPoint &position)
476 Set the bottom-left corner of the rectangle to the given \a
477 position. May change the size, but will never change the
478 top-right corner of the rectangle.
480 \sa bottomLeft(), moveBottomLeft()
484 \fn QPoint QRect::topLeft() const
486 Returns the position of the rectangle's top-left corner.
488 \sa setTopLeft(), top(), left()
492 \fn QPoint QRect::bottomRight() const
494 Returns the position of the rectangle's bottom-right corner.
496 Note that for historical reasons this function returns
497 QPoint(left() + width() -1, top() + height() - 1).
499 \sa setBottomRight(), bottom(), right()
503 \fn QPoint QRect::topRight() const
505 Returns the position of the rectangle's top-right corner.
507 Note that for historical reasons this function returns
508 QPoint(left() + width() -1, top()).
510 \sa setTopRight(), top(), right()
514 \fn QPoint QRect::bottomLeft() const
516 Returns the position of the rectangle's bottom-left corner. Note
517 that for historical reasons this function returns QPoint(left(),
518 top() + height() - 1).
520 \sa setBottomLeft(), bottom(), left()
524 \fn QPoint QRect::center() const
526 Returns the center point of the rectangle.
533 \fn void QRect::getRect(int *x, int *y, int *width, int *height) const
535 Extracts the position of the rectangle's top-left corner to *\a x
536 and *\a y, and its dimensions to *\a width and *\a height.
538 \sa setRect(), getCoords()
543 \fn void QRect::getCoords(int *x1, int *y1, int *x2, int *y2) const
545 Extracts the position of the rectangle's top-left corner to *\a x1
546 and *\a y1, and the position of the bottom-right corner to *\a x2
549 \sa setCoords(), getRect()
553 \fn void QRect::moveLeft(int x)
555 Moves the rectangle horizontally, leaving the rectangle's left
556 edge at the given \a x coordinate. The rectangle's size is
559 \sa left(), setLeft(), moveRight()
563 \fn void QRect::moveTop(int y)
565 Moves the rectangle vertically, leaving the rectangle's top edge
566 at the given \a y coordinate. The rectangle's size is unchanged.
568 \sa top(), setTop(), moveBottom()
573 \fn void QRect::moveRight(int x)
575 Moves the rectangle horizontally, leaving the rectangle's right
576 edge at the given \a x coordinate. The rectangle's size is
579 \sa right(), setRight(), moveLeft()
584 \fn void QRect::moveBottom(int y)
586 Moves the rectangle vertically, leaving the rectangle's bottom
587 edge at the given \a y coordinate. The rectangle's size is
590 \sa bottom(), setBottom(), moveTop()
595 \fn void QRect::moveTopLeft(const QPoint &position)
597 Moves the rectangle, leaving the top-left corner at the given \a
598 position. The rectangle's size is unchanged.
600 \sa setTopLeft(), moveTop(), moveLeft()
605 \fn void QRect::moveBottomRight(const QPoint &position)
607 Moves the rectangle, leaving the bottom-right corner at the given
608 \a position. The rectangle's size is unchanged.
610 \sa setBottomRight(), moveRight(), moveBottom()
615 \fn void QRect::moveTopRight(const QPoint &position)
617 Moves the rectangle, leaving the top-right corner at the given \a
618 position. The rectangle's size is unchanged.
620 \sa setTopRight(), moveTop(), moveRight()
625 \fn void QRect::moveBottomLeft(const QPoint &position)
627 Moves the rectangle, leaving the bottom-left corner at the given
628 \a position. The rectangle's size is unchanged.
630 \sa setBottomLeft(), moveBottom(), moveLeft()
635 \fn void QRect::moveCenter(const QPoint &position)
637 Moves the rectangle, leaving the center point at the given \a
638 position. The rectangle's size is unchanged.
643 void QRect::moveCenter(const QPoint &p)
654 \fn void QRect::moveTo(int x, int y)
656 Moves the rectangle, leaving the top-left corner at the given
657 position (\a x, \a y). The rectangle's size is unchanged.
659 \sa translate(), moveTopLeft()
663 \fn void QRect::moveTo(const QPoint &position)
665 Moves the rectangle, leaving the top-left corner at the given \a
670 \fn void QRect::translate(int dx, int dy)
672 Moves the rectangle \a dx along the x axis and \a dy along the y
673 axis, relative to the current position. Positive values move the
674 rectangle to the right and down.
676 \sa moveTopLeft(), moveTo(), translated()
681 \fn void QRect::translate(const QPoint &offset)
684 Moves the rectangle \a{offset}.\l{QPoint::x()}{x()} along the x
685 axis and \a{offset}.\l{QPoint::y()}{y()} along the y axis,
686 relative to the current position.
691 \fn QRect QRect::translated(int dx, int dy) const
693 Returns a copy of the rectangle that is translated \a dx along the
694 x axis and \a dy along the y axis, relative to the current
695 position. Positive values move the rectangle to the right and
704 \fn QRect QRect::translated(const QPoint &offset) const
708 Returns a copy of the rectangle that is translated
709 \a{offset}.\l{QPoint::x()}{x()} along the x axis and
710 \a{offset}.\l{QPoint::y()}{y()} along the y axis, relative to the
716 \fn void QRect::setRect(int x, int y, int width, int height)
718 Sets the coordinates of the rectangle's top-left corner to (\a{x},
719 \a{y}), and its size to the given \a width and \a height.
721 \sa getRect(), setCoords()
726 \fn void QRect::setCoords(int x1, int y1, int x2, int y2)
728 Sets the coordinates of the rectangle's top-left corner to (\a x1,
729 \a y1), and the coordinates of its bottom-right corner to (\a x2,
732 \sa getCoords(), setRect()
736 /*! \fn QRect QRect::adjusted(int dx1, int dy1, int dx2, int dy2) const
738 Returns a new rectangle with \a dx1, \a dy1, \a dx2 and \a dy2
739 added respectively to the existing coordinates of this rectangle.
744 /*! \fn void QRect::adjust(int dx1, int dy1, int dx2, int dy2)
746 Adds \a dx1, \a dy1, \a dx2 and \a dy2 respectively to the
747 existing coordinates of the rectangle.
749 \sa adjusted(), setRect()
753 \fn QSize QRect::size() const
755 Returns the size of the rectangle.
757 \sa setSize(), width(), height()
761 \fn int QRect::width() const
763 Returns the width of the rectangle.
765 \sa setWidth(), height(), size()
769 \fn int QRect::height() const
771 Returns the height of the rectangle.
773 \sa setHeight(), width(), size()
777 \fn void QRect::setWidth(int width)
779 Sets the width of the rectangle to the given \a width. The right
780 edge is changed, but not the left one.
782 \sa width(), setSize()
787 \fn void QRect::setHeight(int height)
789 Sets the height of the rectangle to the given \a height. The bottom
790 edge is changed, but not the top one.
792 \sa height(), setSize()
797 \fn void QRect::setSize(const QSize &size)
799 Sets the size of the rectangle to the given \a size. The top-left
802 \sa size(), setWidth(), setHeight()
807 \fn bool QRect::contains(const QPoint &point, bool proper) const
809 Returns true if the given \a point is inside or on the edge of
810 the rectangle, otherwise returns false. If \a proper is true, this
811 function only returns true if the given \a point is \e inside the
812 rectangle (i.e., not on the edge).
817 bool QRect::contains(const QPoint &p, bool proper) const
828 if (p.x() <= l || p.x() >= r)
831 if (p.x() < l || p.x() > r)
843 if (p.y() <= t || p.y() >= b)
846 if (p.y() < t || p.y() > b)
854 \fn bool QRect::contains(int x, int y, bool proper) const
857 Returns true if the point (\a x, \a y) is inside or on the edge of
858 the rectangle, otherwise returns false. If \a proper is true, this
859 function only returns true if the point is entirely inside the
860 rectangle(not on the edge).
864 \fn bool QRect::contains(int x, int y) const
867 Returns true if the point (\a x, \a y) is inside this rectangle,
868 otherwise returns false.
872 \fn bool QRect::contains(const QRect &rectangle, bool proper) const
875 Returns true if the given \a rectangle is inside this rectangle.
876 otherwise returns false. If \a proper is true, this function only
877 returns true if the \a rectangle is entirely inside this
878 rectangle (not on the edge).
881 bool QRect::contains(const QRect &r, bool proper) const
883 if (isNull() || r.isNull())
895 if (r.x2 - r.x1 + 1 < 0)
901 if (l2 <= l1 || r2 >= r1)
904 if (l2 < l1 || r2 > r1)
917 if (r.y2 - r.y1 + 1 < 0)
923 if (t2 <= t1 || b2 >= b1)
926 if (t2 < t1 || b2 > b1)
934 \fn QRect& QRect::operator|=(const QRect &rectangle)
936 Unites this rectangle with the given \a rectangle.
938 \sa united(), operator|()
942 \fn QRect& QRect::operator&=(const QRect &rectangle)
944 Intersects this rectangle with the given \a rectangle.
946 \sa intersected(), operator&()
951 \fn QRect QRect::operator|(const QRect &rectangle) const
953 Returns the bounding rectangle of this rectangle and the given \a
956 \sa operator|=(), united()
959 QRect QRect::operator|(const QRect &r) const
975 if (r.x2 - r.x1 + 1 < 0)
989 if (r.y2 - r.y1 + 1 < 0)
995 tmp.x1 = qMin(l1, l2);
996 tmp.x2 = qMax(r1, r2);
997 tmp.y1 = qMin(t1, t2);
998 tmp.y2 = qMax(b1, b2);
1003 \fn QRect QRect::unite(const QRect &rectangle) const
1006 Use united(\a rectangle) instead.
1010 \fn QRect QRect::united(const QRect &rectangle) const
1013 Returns the bounding rectangle of this rectangle and the given \a rectangle.
1015 \image qrect-unite.png
1022 \fn QRect QRect::operator&(const QRect &rectangle) const
1024 Returns the intersection of this rectangle and the given \a
1025 rectangle. Returns an empty rectangle if there is no intersection.
1027 \sa operator&=(), intersected()
1030 QRect QRect::operator&(const QRect &r) const
1032 if (isNull() || r.isNull())
1037 if (x2 - x1 + 1 < 0)
1044 if (r.x2 - r.x1 + 1 < 0)
1049 if (l1 > r2 || l2 > r1)
1054 if (y2 - y1 + 1 < 0)
1061 if (r.y2 - r.y1 + 1 < 0)
1066 if (t1 > b2 || t2 > b1)
1070 tmp.x1 = qMax(l1, l2);
1071 tmp.x2 = qMin(r1, r2);
1072 tmp.y1 = qMax(t1, t2);
1073 tmp.y2 = qMin(b1, b2);
1078 \fn QRect QRect::intersect(const QRect &rectangle) const
1081 Use intersected(\a rectangle) instead.
1085 \fn QRect QRect::intersected(const QRect &rectangle) const
1088 Returns the intersection of this rectangle and the given \a
1089 rectangle. Note that \c{r.intersected(s)} is equivalent to \c{r & s}.
1091 \image qrect-intersect.png
1093 \sa intersects(), united(), operator&=()
1097 \fn bool QRect::intersects(const QRect &rectangle) const
1099 Returns true if this rectangle intersects with the given \a
1100 rectangle (i.e., there is at least one pixel that is within both
1101 rectangles), otherwise returns false.
1103 The intersection rectangle can be retrieved using the intersected()
1109 bool QRect::intersects(const QRect &r) const
1111 if (isNull() || r.isNull())
1116 if (x2 - x1 + 1 < 0)
1123 if (r.x2 - r.x1 + 1 < 0)
1128 if (l1 > r2 || l2 > r1)
1133 if (y2 - y1 + 1 < 0)
1140 if (r.y2 - r.y1 + 1 < 0)
1145 if (t1 > b2 || t2 > b1)
1152 \fn bool operator==(const QRect &r1, const QRect &r2)
1155 Returns true if the rectangles \a r1 and \a r2 are equal,
1156 otherwise returns false.
1161 \fn bool operator!=(const QRect &r1, const QRect &r2)
1164 Returns true if the rectangles \a r1 and \a r2 are different, otherwise
1169 /*****************************************************************************
1170 QRect stream functions
1171 *****************************************************************************/
1172 #ifndef QT_NO_DATASTREAM
1174 \fn QDataStream &operator<<(QDataStream &stream, const QRect &rectangle)
1177 Writes the given \a rectangle to the given \a stream, and returns
1178 a reference to the stream.
1180 \sa {Serializing Qt Data Types}
1183 QDataStream &operator<<(QDataStream &s, const QRect &r)
1185 if (s.version() == 1)
1186 s << (qint16)r.left() << (qint16)r.top()
1187 << (qint16)r.right() << (qint16)r.bottom();
1189 s << (qint32)r.left() << (qint32)r.top()
1190 << (qint32)r.right() << (qint32)r.bottom();
1195 \fn QDataStream &operator>>(QDataStream &stream, QRect &rectangle)
1198 Reads a rectangle from the given \a stream into the given \a
1199 rectangle, and returns a reference to the stream.
1201 \sa {Serializing Qt Data Types}
1204 QDataStream &operator>>(QDataStream &s, QRect &r)
1206 if (s.version() == 1) {
1207 qint16 x1, y1, x2, y2;
1208 s >> x1; s >> y1; s >> x2; s >> y2;
1209 r.setCoords(x1, y1, x2, y2);
1212 qint32 x1, y1, x2, y2;
1213 s >> x1; s >> y1; s >> x2; s >> y2;
1214 r.setCoords(x1, y1, x2, y2);
1219 #endif // QT_NO_DATASTREAM
1222 #ifndef QT_NO_DEBUG_STREAM
1223 QDebug operator<<(QDebug dbg, const QRect &r) {
1224 dbg.nospace() << "QRect(" << r.x() << ',' << r.y() << ' '
1225 << r.width() << 'x' << r.height() << ')';
1234 \brief The QRectF class defines a rectangle in the plane using floating
1237 A rectangle is normally expressed as an upper-left corner and a
1238 size. The size (width and height) of a QRectF is always equivalent
1239 to the mathematical rectangle that forms the basis for its
1242 A QRectF can be constructed with a set of left, top, width and
1243 height integers, or from a QPoint and a QSize. The following code
1244 creates two identical rectangles.
1246 \snippet doc/src/snippets/code/src_corelib_tools_qrect.cpp 1
1248 There is also a third constructor creating a QRectF from a QRect,
1249 and a corresponding toRect() function that returns a QRect object
1250 based on the values of this rectangle (note that the coordinates
1251 in the returned rectangle are rounded to the nearest integer).
1253 The QRectF class provides a collection of functions that return
1254 the various rectangle coordinates, and enable manipulation of
1255 these. QRectF also provide functions to move the rectangle
1256 relative to the various coordinates. In addition there is a
1257 moveTo() function that moves the rectangle, leaving its top left
1258 corner at the given coordinates. Alternatively, the translate()
1259 function moves the rectangle the given offset relative to the
1260 current position, and the translated() function returns a
1261 translated copy of this rectangle.
1263 The size() function returns the rectange's dimensions as a
1264 QSize. The dimensions can also be retrieved separately using the
1265 width() and height() functions. To manipulate the dimensions use
1266 the setSize(), setWidth() or setHeight() functions. Alternatively,
1267 the size can be changed by applying either of the functions
1268 setting the rectangle coordinates, for example, setBottom() or
1271 The contains() function tells whether a given point is inside the
1272 rectangle or not, and the intersects() function returns true if
1273 this rectangle intersects with a given rectangle (otherwise
1274 false). The QRectF class also provides the intersected() function
1275 which returns the intersection rectangle, and the united() function
1276 which returns the rectangle that encloses the given rectangle and
1281 \o \inlineimage qrect-intersect.png
1282 \o \inlineimage qrect-unite.png
1288 The isEmpty() function returns true if the rectangle's width or
1289 height is less than, or equal to, 0. Note that an empty rectangle
1290 is not valid: The isValid() function returns true if both width
1291 and height is larger than 0. A null rectangle (isNull() == true)
1292 on the other hand, has both width and height set to 0.
1294 Note that due to the way QRect and QRectF are defined, an
1295 empty QRectF is defined in essentially the same way as QRect.
1297 Finally, QRectF objects can be streamed as well as compared.
1303 When using an \l {QPainter::Antialiasing}{anti-aliased} painter,
1304 the boundary line of a QRectF will be rendered symmetrically on both
1305 sides of the mathematical rectangle's boundary line. But when
1306 using an aliased painter (the default) other rules apply.
1308 Then, when rendering with a one pixel wide pen the QRectF's boundary
1309 line will be rendered to the right and below the mathematical
1310 rectangle's boundary line.
1312 When rendering with a two pixels wide pen the boundary line will
1313 be split in the middle by the mathematical rectangle. This will be
1314 the case whenever the pen is set to an even number of pixels,
1315 while rendering with a pen with an odd number of pixels, the spare
1316 pixel will be rendered to the right and below the mathematical
1317 rectangle as in the one pixel case.
1321 \o \inlineimage qrect-diagram-zero.png
1322 \o \inlineimage qrectf-diagram-one.png
1324 \o Logical representation
1325 \o One pixel wide pen
1327 \o \inlineimage qrectf-diagram-two.png
1328 \o \inlineimage qrectf-diagram-three.png
1330 \o Two pixel wide pen
1331 \o Three pixel wide pen
1334 \section1 Coordinates
1336 The QRectF class provides a collection of functions that return
1337 the various rectangle coordinates, and enable manipulation of
1338 these. QRectF also provide functions to move the rectangle
1339 relative to the various coordinates.
1341 For example: the bottom(), setBottom() and moveBottom() functions:
1342 bottom() returns the y-coordinate of the rectangle's bottom edge,
1343 setBottom() sets the bottom edge of the rectangle to the given y
1344 coordinate (it may change the height, but will never change the
1345 rectangle's top edge) and moveBottom() moves the entire rectangle
1346 vertically, leaving the rectangle's bottom edge at the given y
1347 coordinate and its size unchanged.
1349 \image qrectf-coordinates.png
1351 It is also possible to add offsets to this rectangle's coordinates
1352 using the adjust() function, as well as retrieve a new rectangle
1353 based on adjustments of the original one using the adjusted()
1354 function. If either of the width and height is negative, use the
1355 normalized() function to retrieve a rectangle where the corners
1358 In addition, QRectF provides the getCoords() function which extracts
1359 the position of the rectangle's top-left and bottom-right corner,
1360 and the getRect() function which extracts the rectangle's top-left
1361 corner, width and height. Use the setCoords() and setRect()
1362 function to manipulate the rectangle's coordinates and dimensions
1368 /*****************************************************************************
1369 QRectF member functions
1370 *****************************************************************************/
1373 \fn QRectF::QRectF()
1375 Constructs a null rectangle.
1381 \fn QRectF::QRectF(const QPointF &topLeft, const QSizeF &size)
1383 Constructs a rectangle with the given \a topLeft corner and the given \a size.
1385 \sa setTopLeft(), setSize()
1389 \fn QRectF::QRectF(const QPointF &topLeft, const QPointF &bottomRight)
1392 Constructs a rectangle with the given \a topLeft and \a bottomRight corners.
1394 \sa setTopLeft(), setBottomRight()
1398 \fn QRectF::QRectF(qreal x, qreal y, qreal width, qreal height)
1400 Constructs a rectangle with (\a x, \a y) as its top-left corner
1401 and the given \a width and \a height.
1407 \fn QRectF::QRectF(const QRect &rectangle)
1409 Constructs a QRectF rectangle from the given QRect \a rectangle.
1415 \fn bool QRectF::isNull() const
1417 Returns true if the rectangle is a null rectangle, otherwise returns false.
1419 A null rectangle has both the width and the height set to 0. A
1420 null rectangle is also empty, and hence not valid.
1422 \sa isEmpty(), isValid()
1426 \fn bool QRectF::isEmpty() const
1428 Returns true if the rectangle is empty, otherwise returns false.
1430 An empty rectangle has width() <= 0 or height() <= 0. An empty
1431 rectangle is not valid (i.e., isEmpty() == !isValid()).
1433 Use the normalized() function to retrieve a rectangle where the
1434 corners are swapped.
1436 \sa isNull(), isValid(), normalized()
1440 \fn bool QRectF::isValid() const
1442 Returns true if the rectangle is valid, otherwise returns false.
1444 A valid rectangle has a width() > 0 and height() > 0. Note that
1445 non-trivial operations like intersections are not defined for
1446 invalid rectangles. A valid rectangle is not empty (i.e., isValid()
1449 \sa isNull(), isEmpty(), normalized()
1454 Returns a normalized rectangle; i.e., a rectangle that has a
1455 non-negative width and height.
1457 If width() < 0 the function swaps the left and right corners, and
1458 it swaps the top and bottom corners if height() < 0.
1460 \sa isValid(), isEmpty()
1463 QRectF QRectF::normalized() const
1478 \fn qreal QRectF::x() const
1480 Returns the x-coordinate of the rectangle's left edge. Equivalent
1484 \sa setX(), y(), topLeft()
1488 \fn qreal QRectF::y() const
1490 Returns the y-coordinate of the rectangle's top edge. Equivalent
1493 \sa setY(), x(), topLeft()
1498 \fn void QRectF::setLeft(qreal x)
1500 Sets the left edge of the rectangle to the given \a x
1501 coordinate. May change the width, but will never change the right
1502 edge of the rectangle.
1504 Equivalent to setX().
1506 \sa left(), moveLeft()
1510 \fn void QRectF::setTop(qreal y)
1512 Sets the top edge of the rectangle to the given \a y coordinate. May
1513 change the height, but will never change the bottom edge of the
1516 Equivalent to setY().
1518 \sa top(), moveTop()
1522 \fn void QRectF::setRight(qreal x)
1524 Sets the right edge of the rectangle to the given \a x
1525 coordinate. May change the width, but will never change the left
1526 edge of the rectangle.
1528 \sa right(), moveRight()
1532 \fn void QRectF::setBottom(qreal y)
1534 Sets the bottom edge of the rectangle to the given \a y
1535 coordinate. May change the height, but will never change the top
1536 edge of the rectangle.
1538 \sa bottom(), moveBottom()
1542 \fn void QRectF::setX(qreal x)
1544 Sets the left edge of the rectangle to the given \a x
1545 coordinate. May change the width, but will never change the right
1546 edge of the rectangle.
1548 Equivalent to setLeft().
1550 \sa x(), setY(), setTopLeft()
1554 \fn void QRectF::setY(qreal y)
1556 Sets the top edge of the rectangle to the given \a y
1557 coordinate. May change the height, but will never change the
1558 bottom edge of the rectangle.
1560 Equivalent to setTop().
1562 \sa y(), setX(), setTopLeft()
1566 \fn void QRectF::setTopLeft(const QPointF &position)
1568 Set the top-left corner of the rectangle to the given \a
1569 position. May change the size, but will never change the
1570 bottom-right corner of the rectangle.
1572 \sa topLeft(), moveTopLeft()
1576 \fn void QRectF::setBottomRight(const QPointF &position)
1578 Set the bottom-right corner of the rectangle to the given \a
1579 position. May change the size, but will never change the
1580 top-left corner of the rectangle.
1582 \sa bottomRight(), moveBottomRight()
1586 \fn void QRectF::setTopRight(const QPointF &position)
1588 Set the top-right corner of the rectangle to the given \a
1589 position. May change the size, but will never change the
1590 bottom-left corner of the rectangle.
1592 \sa topRight(), moveTopRight()
1596 \fn void QRectF::setBottomLeft(const QPointF &position)
1598 Set the bottom-left corner of the rectangle to the given \a
1599 position. May change the size, but will never change the
1600 top-right corner of the rectangle.
1602 \sa bottomLeft(), moveBottomLeft()
1606 \fn QPointF QRectF::center() const
1608 Returns the center point of the rectangle.
1615 \fn void QRectF::getRect(qreal *x, qreal *y, qreal *width, qreal *height) const
1617 Extracts the position of the rectangle's top-left corner to *\a x and
1618 *\a y, and its dimensions to *\a width and *\a height.
1620 \sa setRect(), getCoords()
1625 \fn void QRectF::getCoords(qreal *x1, qreal *y1, qreal *x2, qreal *y2) const
1627 Extracts the position of the rectangle's top-left corner to *\a x1
1628 and *\a y1, and the position of the bottom-right corner to *\a x2 and
1631 \sa setCoords(), getRect()
1635 \fn void QRectF::moveLeft(qreal x)
1637 Moves the rectangle horizontally, leaving the rectangle's left
1638 edge at the given \a x coordinate. The rectangle's size is
1641 \sa left(), setLeft(), moveRight()
1645 \fn void QRectF::moveTop(qreal y)
1647 Moves the rectangle vertically, leaving the rectangle's top line
1648 at the given \a y coordinate. The rectangle's size is unchanged.
1650 \sa top(), setTop(), moveBottom()
1655 \fn void QRectF::moveRight(qreal x)
1657 Moves the rectangle horizontally, leaving the rectangle's right
1658 edge at the given \a x coordinate. The rectangle's size is
1661 \sa right(), setRight(), moveLeft()
1666 \fn void QRectF::moveBottom(qreal y)
1668 Moves the rectangle vertically, leaving the rectangle's bottom
1669 edge at the given \a y coordinate. The rectangle's size is
1672 \sa bottom(), setBottom(), moveTop()
1677 \fn void QRectF::moveTopLeft(const QPointF &position)
1679 Moves the rectangle, leaving the top-left corner at the given \a
1680 position. The rectangle's size is unchanged.
1682 \sa setTopLeft(), moveTop(), moveLeft()
1687 \fn void QRectF::moveBottomRight(const QPointF &position)
1689 Moves the rectangle, leaving the bottom-right corner at the given
1690 \a position. The rectangle's size is unchanged.
1692 \sa setBottomRight(), moveBottom(), moveRight()
1697 \fn void QRectF::moveTopRight(const QPointF &position)
1699 Moves the rectangle, leaving the top-right corner at the given
1700 \a position. The rectangle's size is unchanged.
1702 \sa setTopRight(), moveTop(), moveRight()
1707 \fn void QRectF::moveBottomLeft(const QPointF &position)
1709 Moves the rectangle, leaving the bottom-left corner at the given
1710 \a position. The rectangle's size is unchanged.
1712 \sa setBottomLeft(), moveBottom(), moveLeft()
1717 \fn void QRectF::moveTo(qreal x, qreal y)
1719 Moves the rectangle, leaving the top-left corner at the given
1720 position (\a x, \a y). The rectangle's size is unchanged.
1722 \sa translate(), moveTopLeft()
1726 \fn void QRectF::moveTo(const QPointF &position)
1729 Moves the rectangle, leaving the top-left corner at the given \a
1734 \fn void QRectF::translate(qreal dx, qreal dy)
1736 Moves the rectangle \a dx along the x-axis and \a dy along the y-axis,
1737 relative to the current position. Positive values move the rectangle to the
1738 right and downwards.
1740 \sa moveTopLeft(), moveTo(), translated()
1745 \fn void QRectF::translate(const QPointF &offset)
1748 Moves the rectangle \a{offset}.\l{QPointF::x()}{x()} along the x
1749 axis and \a{offset}.\l{QPointF::y()}{y()} along the y axis,
1750 relative to the current position.
1755 \fn QRectF QRectF::translated(qreal dx, qreal dy) const
1757 Returns a copy of the rectangle that is translated \a dx along the
1758 x axis and \a dy along the y axis, relative to the current
1759 position. Positive values move the rectangle to the right and
1767 \fn QRectF QRectF::translated(const QPointF &offset) const
1770 Returns a copy of the rectangle that is translated
1771 \a{offset}.\l{QPointF::x()}{x()} along the x axis and
1772 \a{offset}.\l{QPointF::y()}{y()} along the y axis, relative to the
1778 \fn void QRectF::setRect(qreal x, qreal y, qreal width, qreal height)
1780 Sets the coordinates of the rectangle's top-left corner to (\a x,
1781 \a y), and its size to the given \a width and \a height.
1783 \sa getRect(), setCoords()
1788 \fn void QRectF::setCoords(qreal x1, qreal y1, qreal x2, qreal y2)
1790 Sets the coordinates of the rectangle's top-left corner to (\a x1,
1791 \a y1), and the coordinates of its bottom-right corner to (\a x2,
1794 \sa getCoords() setRect()
1798 \fn QRectF QRectF::adjusted(qreal dx1, qreal dy1, qreal dx2, qreal dy2) const
1800 Returns a new rectangle with \a dx1, \a dy1, \a dx2 and \a dy2
1801 added respectively to the existing coordinates of this rectangle.
1806 /*! \fn void QRectF::adjust(qreal dx1, qreal dy1, qreal dx2, qreal dy2)
1808 Adds \a dx1, \a dy1, \a dx2 and \a dy2 respectively to the
1809 existing coordinates of the rectangle.
1811 \sa adjusted(), setRect()
1814 \fn QSizeF QRectF::size() const
1816 Returns the size of the rectangle.
1818 \sa setSize(), width(), height()
1822 \fn qreal QRectF::width() const
1824 Returns the width of the rectangle.
1826 \sa setWidth(), height(), size()
1830 \fn qreal QRectF::height() const
1832 Returns the height of the rectangle.
1834 \sa setHeight(), width(), size()
1838 \fn void QRectF::setWidth(qreal width)
1840 Sets the width of the rectangle to the given \a width. The right
1841 edge is changed, but not the left one.
1843 \sa width(), setSize()
1848 \fn void QRectF::setHeight(qreal height)
1850 Sets the height of the rectangle to the given \a height. The bottom
1851 edge is changed, but not the top one.
1853 \sa height(), setSize()
1858 \fn void QRectF::setSize(const QSizeF &size)
1860 Sets the size of the rectangle to the given \a size. The top-left
1861 corner is not moved.
1863 \sa size(), setWidth(), setHeight()
1868 \fn bool QRectF::contains(const QPointF &point) const
1870 Returns true if the given \a point is inside or on the edge of the
1871 rectangle; otherwise returns false.
1876 bool QRectF::contains(const QPointF &p) const
1884 if (l == r) // null rect
1887 if (p.x() < l || p.x() > r)
1896 if (t == b) // null rect
1899 if (p.y() < t || p.y() > b)
1907 \fn bool QRectF::contains(qreal x, qreal y) const
1910 Returns true if the point (\a x, \a y) is inside or on the edge of
1911 the rectangle; otherwise returns false.
1915 \fn bool QRectF::contains(const QRectF &rectangle) const
1918 Returns true if the given \a rectangle is inside this rectangle;
1919 otherwise returns false.
1922 bool QRectF::contains(const QRectF &r) const
1930 if (l1 == r1) // null rect
1939 if (l2 == r2) // null rect
1942 if (l2 < l1 || r2 > r1)
1951 if (t1 == b1) // null rect
1960 if (t2 == b2) // null rect
1963 if (t2 < t1 || b2 > b1)
1970 \fn qreal QRectF::left() const
1972 Returns the x-coordinate of the rectangle's left edge. Equivalent
1975 \sa setLeft(), topLeft(), bottomLeft()
1979 \fn qreal QRectF::top() const
1981 Returns the y-coordinate of the rectangle's top edge. Equivalent
1984 \sa setTop(), topLeft(), topRight()
1988 \fn qreal QRectF::right() const
1990 Returns the x-coordinate of the rectangle's right edge.
1992 \sa setRight(), topRight(), bottomRight()
1996 \fn qreal QRectF::bottom() const
1998 Returns the y-coordinate of the rectangle's bottom edge.
2000 \sa setBottom(), bottomLeft(), bottomRight()
2004 \fn QPointF QRectF::topLeft() const
2006 Returns the position of the rectangle's top-left corner.
2008 \sa setTopLeft(), top(), left()
2012 \fn QPointF QRectF::bottomRight() const
2014 Returns the position of the rectangle's bottom-right corner.
2016 \sa setBottomRight(), bottom(), right()
2020 \fn QPointF QRectF::topRight() const
2022 Returns the position of the rectangle's top-right corner.
2024 \sa setTopRight(), top(), right()
2028 \fn QPointF QRectF::bottomLeft() const
2030 Returns the position of the rectangle's bottom-left corner.
2032 \sa setBottomLeft(), bottom(), left()
2036 \fn QRectF& QRectF::operator|=(const QRectF &rectangle)
2038 Unites this rectangle with the given \a rectangle.
2040 \sa united(), operator|()
2044 \fn QRectF& QRectF::operator&=(const QRectF &rectangle)
2046 Intersects this rectangle with the given \a rectangle.
2048 \sa intersected(), operator|=()
2053 \fn QRectF QRectF::operator|(const QRectF &rectangle) const
2055 Returns the bounding rectangle of this rectangle and the given \a rectangle.
2057 \sa united(), operator|=()
2060 QRectF QRectF::operator|(const QRectF &r) const
2075 left = qMin(left, r.xp + r.w);
2076 right = qMax(right, r.xp);
2078 left = qMin(left, r.xp);
2079 right = qMax(right, r.xp + r.w);
2090 top = qMin(top, r.yp + r.h);
2091 bottom = qMax(bottom, r.yp);
2093 top = qMin(top, r.yp);
2094 bottom = qMax(bottom, r.yp + r.h);
2097 return QRectF(left, top, right - left, bottom - top);
2101 \fn QRectF QRectF::unite(const QRectF &rectangle) const
2104 Use united(\a rectangle) instead.
2108 \fn QRectF QRectF::united(const QRectF &rectangle) const
2111 Returns the bounding rectangle of this rectangle and the given \a
2114 \image qrect-unite.png
2121 \fn QRectF QRectF::operator &(const QRectF &rectangle) const
2123 Returns the intersection of this rectangle and the given \a
2124 rectangle. Returns an empty rectangle if there is no intersection.
2126 \sa operator&=(), intersected()
2129 QRectF QRectF::operator&(const QRectF &r) const
2137 if (l1 == r1) // null rect
2146 if (l2 == r2) // null rect
2149 if (l1 >= r2 || l2 >= r1)
2158 if (t1 == b1) // null rect
2167 if (t2 == b2) // null rect
2170 if (t1 >= b2 || t2 >= b1)
2174 tmp.xp = qMax(l1, l2);
2175 tmp.yp = qMax(t1, t2);
2176 tmp.w = qMin(r1, r2) - tmp.xp;
2177 tmp.h = qMin(b1, b2) - tmp.yp;
2182 \fn QRectF QRectF::intersect(const QRectF &rectangle) const
2185 Use intersected(\a rectangle) instead.
2189 \fn QRectF QRectF::intersected(const QRectF &rectangle) const
2192 Returns the intersection of this rectangle and the given \a
2193 rectangle. Note that \c {r.intersected(s)} is equivalent to \c
2196 \image qrect-intersect.png
2198 \sa intersects(), united(), operator&=()
2202 \fn bool QRectF::intersects(const QRectF &rectangle) const
2204 Returns true if this rectangle intersects with the given \a
2205 rectangle (i.e. there is a non-empty area of overlap between
2206 them), otherwise returns false.
2208 The intersection rectangle can be retrieved using the intersected()
2214 bool QRectF::intersects(const QRectF &r) const
2222 if (l1 == r1) // null rect
2231 if (l2 == r2) // null rect
2234 if (l1 >= r2 || l2 >= r1)
2243 if (t1 == b1) // null rect
2252 if (t2 == b2) // null rect
2255 if (t1 >= b2 || t2 >= b1)
2262 \fn QRect QRectF::toRect() const
2264 Returns a QRect based on the values of this rectangle. Note that the
2265 coordinates in the returned rectangle are rounded to the nearest integer.
2267 \sa QRectF(), toAlignedRect()
2271 \fn QRect QRectF::toAlignedRect() const
2274 Returns a QRect based on the values of this rectangle that is the
2275 smallest possible integer rectangle that completely contains this
2281 QRect QRectF::toAlignedRect() const
2283 int xmin = int(qFloor(xp));
2284 int xmax = int(qCeil(xp + w));
2285 int ymin = int(qFloor(yp));
2286 int ymax = int(qCeil(yp + h));
2287 return QRect(xmin, ymin, xmax - xmin, ymax - ymin);
2291 \fn void QRectF::moveCenter(const QPointF &position)
2293 Moves the rectangle, leaving the center point at the given \a
2294 position. The rectangle's size is unchanged.
2300 \fn bool operator==(const QRectF &r1, const QRectF &r2)
2303 Returns true if the rectangles \a r1 and \a r2 are equal,
2304 otherwise returns false.
2309 \fn bool operator!=(const QRectF &r1, const QRectF &r2)
2312 Returns true if the rectangles \a r1 and \a r2 are different, otherwise
2316 /*****************************************************************************
2317 QRectF stream functions
2318 *****************************************************************************/
2319 #ifndef QT_NO_DATASTREAM
2321 \fn QDataStream &operator<<(QDataStream &stream, const QRectF &rectangle)
2325 Writes the \a rectangle to the \a stream, and returns a reference to the
2328 \sa {Serializing Qt Data Types}
2331 QDataStream &operator<<(QDataStream &s, const QRectF &r)
2333 s << double(r.x()) << double(r.y()) << double(r.width()) << double(r.height());
2338 \fn QDataStream &operator>>(QDataStream &stream, QRectF &rectangle)
2342 Reads a \a rectangle from the \a stream, and returns a reference to the
2345 \sa {Serializing Qt Data Types}
2348 QDataStream &operator>>(QDataStream &s, QRectF &r)
2355 r.setRect(qreal(x), qreal(y), qreal(w), qreal(h));
2359 #endif // QT_NO_DATASTREAM
2362 #ifndef QT_NO_DEBUG_STREAM
2363 QDebug operator<<(QDebug dbg, const QRectF &r) {
2364 dbg.nospace() << "QRectF(" << r.x() << ',' << r.y() << ' '
2365 << r.width() << 'x' << r.height() << ')';