tools/qrect.cpp

Source codeSwitch to Preprocessed file
LineSource CodeCoverage
1/**************************************************************************** -
2** -
3** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -
4** Contact: http://www.qt-project.org/legal -
5** -
6** This file is part of the QtCore module of the Qt Toolkit. -
7** -
8** $QT_BEGIN_LICENSE:LGPL$ -
9** Commercial License Usage -
10** Licensees holding valid commercial Qt licenses may use this file in -
11** accordance with the commercial license agreement provided with the -
12** Software or, alternatively, in accordance with the terms contained in -
13** a written agreement between you and Digia. For licensing terms and -
14** conditions see http://qt.digia.com/licensing. For further information -
15** use the contact form at http://qt.digia.com/contact-us. -
16** -
17** GNU Lesser General Public License Usage -
18** Alternatively, this file may be used under the terms of the GNU Lesser -
19** General Public License version 2.1 as published by the Free Software -
20** Foundation and appearing in the file LICENSE.LGPL included in the -
21** packaging of this file. Please review the following information to -
22** ensure the GNU Lesser General Public License version 2.1 requirements -
23** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -
24** -
25** In addition, as a special exception, Digia gives you certain additional -
26** rights. These rights are described in the Digia Qt LGPL Exception -
27** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -
28** -
29** GNU General Public License Usage -
30** Alternatively, this file may be used under the terms of the GNU -
31** General Public License version 3.0 as published by the Free Software -
32** Foundation and appearing in the file LICENSE.GPL included in the -
33** packaging of this file. Please review the following information to -
34** ensure the GNU General Public License version 3.0 requirements will be -
35** met: http://www.gnu.org/copyleft/gpl.html. -
36** -
37** -
38** $QT_END_LICENSE$ -
39** -
40****************************************************************************/ -
41 -
42#include "qrect.h" -
43#include "qdatastream.h" -
44#include "qdebug.h" -
45#include "qmath.h" -
46 -
47#include <math.h> -
48 -
49QT_BEGIN_NAMESPACE -
50 -
51/*! -
52 \class QRect -
53 \inmodule QtCore -
54 \ingroup painting -
55 -
56 \brief The QRect class defines a rectangle in the plane using -
57 integer precision. -
58 -
59 A rectangle is normally expressed as an upper-left corner and a -
60 size. The size (width and height) of a QRect is always equivalent -
61 to the mathematical rectangle that forms the basis for its -
62 rendering. -
63 -
64 A QRect can be constructed with a set of left, top, width and -
65 height integers, or from a QPoint and a QSize. The following code -
66 creates two identical rectangles. -
67 -
68 \snippet code/src_corelib_tools_qrect.cpp 0 -
69 -
70 There is a third constructor that creates a QRect using the -
71 top-left and bottom-right coordinates, but we recommend that you -
72 avoid using it. The rationale is that for historical reasons the -
73 values returned by the bottom() and right() functions deviate from -
74 the true bottom-right corner of the rectangle. -
75 -
76 The QRect class provides a collection of functions that return the -
77 various rectangle coordinates, and enable manipulation of -
78 these. QRect also provide functions to move the rectangle relative -
79 to the various coordinates. In addition there is a moveTo() -
80 function that moves the rectangle, leaving its top left corner at -
81 the given coordinates. Alternatively, the translate() function -
82 moves the rectangle the given offset relative to the current -
83 position, and the translated() function returns a translated copy -
84 of this rectangle. -
85 -
86 The size() function returns the rectange's dimensions as a -
87 QSize. The dimensions can also be retrieved separately using the -
88 width() and height() functions. To manipulate the dimensions use -
89 the setSize(), setWidth() or setHeight() functions. Alternatively, -
90 the size can be changed by applying either of the functions -
91 setting the rectangle coordinates, for example, setBottom() or -
92 setRight(). -
93 -
94 The contains() function tells whether a given point is inside the -
95 rectangle or not, and the intersects() function returns true if -
96 this rectangle intersects with a given rectangle. The QRect class -
97 also provides the intersected() function which returns the -
98 intersection rectangle, and the united() function which returns the -
99 rectangle that encloses the given rectangle and this: -
100 -
101 \table -
102 \row -
103 \li \inlineimage qrect-intersect.png -
104 \li \inlineimage qrect-unite.png -
105 \row -
106 \li intersected() -
107 \li united() -
108 \endtable -
109 -
110 The isEmpty() function returns true if left() > right() or top() > -
111 bottom(). Note that an empty rectangle is not valid: The isValid() -
112 function returns true if left() <= right() \e and top() <= -
113 bottom(). A null rectangle (isNull() == true) on the other hand, -
114 has both width and height set to 0. -
115 -
116 Note that due to the way QRect and QRectF are defined, an -
117 empty QRect is defined in essentially the same way as QRectF. -
118 -
119 Finally, QRect objects can be streamed as well as compared. -
120 -
121 \tableofcontents -
122 -
123 \section1 Rendering -
124 -
125 When using an \l {QPainter::Antialiasing}{anti-aliased} painter, -
126 the boundary line of a QRect will be rendered symmetrically on -
127 both sides of the mathematical rectangle's boundary line. But when -
128 using an aliased painter (the default) other rules apply. -
129 -
130 Then, when rendering with a one pixel wide pen the QRect's boundary -
131 line will be rendered to the right and below the mathematical -
132 rectangle's boundary line. -
133 -
134 When rendering with a two pixels wide pen the boundary line will -
135 be split in the middle by the mathematical rectangle. This will be -
136 the case whenever the pen is set to an even number of pixels, -
137 while rendering with a pen with an odd number of pixels, the spare -
138 pixel will be rendered to the right and below the mathematical -
139 rectangle as in the one pixel case. -
140 -
141 \table -
142 \row -
143 \li \inlineimage qrect-diagram-zero.png -
144 \li \inlineimage qrect-diagram-one.png -
145 \row -
146 \li Logical representation -
147 \li One pixel wide pen -
148 \row -
149 \li \inlineimage qrect-diagram-two.png -
150 \li \inlineimage qrect-diagram-three.png -
151 \row -
152 \li Two pixel wide pen -
153 \li Three pixel wide pen -
154 \endtable -
155 -
156 \section1 Coordinates -
157 -
158 The QRect class provides a collection of functions that return the -
159 various rectangle coordinates, and enable manipulation of -
160 these. QRect also provide functions to move the rectangle relative -
161 to the various coordinates. -
162 -
163 For example the left(), setLeft() and moveLeft() functions as an -
164 example: left() returns the x-coordinate of the rectangle's left -
165 edge, setLeft() sets the left edge of the rectangle to the given x -
166 coordinate (it may change the width, but will never change the -
167 rectangle's right edge) and moveLeft() moves the entire rectangle -
168 horizontally, leaving the rectangle's left edge at the given x -
169 coordinate and its size unchanged. -
170 -
171 \image qrect-coordinates.png -
172 -
173 Note that for historical reasons the values returned by the -
174 bottom() and right() functions deviate from the true bottom-right -
175 corner of the rectangle: The right() function returns \e { left() -
176 + width() - 1} and the bottom() function returns \e {top() + -
177 height() - 1}. The same is the case for the point returned by the -
178 bottomRight() convenience function. In addition, the x and y -
179 coordinate of the topRight() and bottomLeft() functions, -
180 respectively, contain the same deviation from the true right and -
181 bottom edges. -
182 -
183 We recommend that you use x() + width() and y() + height() to find -
184 the true bottom-right corner, and avoid right() and -
185 bottom(). Another solution is to use QRectF: The QRectF class -
186 defines a rectangle in the plane using floating point accuracy for -
187 coordinates, and the QRectF::right() and QRectF::bottom() -
188 functions \e do return the right and bottom coordinates. -
189 -
190 It is also possible to add offsets to this rectangle's coordinates -
191 using the adjust() function, as well as retrieve a new rectangle -
192 based on adjustments of the original one using the adjusted() -
193 function. If either of the width and height is negative, use the -
194 normalized() function to retrieve a rectangle where the corners -
195 are swapped. -
196 -
197 In addition, QRect provides the getCoords() function which extracts -
198 the position of the rectangle's top-left and bottom-right corner, -
199 and the getRect() function which extracts the rectangle's top-left -
200 corner, width and height. Use the setCoords() and setRect() -
201 function to manipulate the rectangle's coordinates and dimensions -
202 in one go. -
203 -
204 \sa QRectF, QRegion -
205*/ -
206 -
207/***************************************************************************** -
208 QRect member functions -
209 *****************************************************************************/ -
210 -
211/*! -
212 \fn QRect::QRect() -
213 -
214 Constructs a null rectangle. -
215 -
216 \sa isNull() -
217*/ -
218 -
219/*! -
220 \fn QRect::QRect(const QPoint &topLeft, const QPoint &bottomRight) -
221 -
222 Constructs a rectangle with the given \a topLeft and \a bottomRight corners. -
223 -
224 \sa setTopLeft(), setBottomRight() -
225*/ -
226 -
227 -
228/*! -
229 \fn QRect::QRect(const QPoint &topLeft, const QSize &size) -
230 -
231 Constructs a rectangle with the given \a topLeft corner and the -
232 given \a size. -
233 -
234 \sa setTopLeft(), setSize() -
235*/ -
236 -
237 -
238/*! -
239 \fn QRect::QRect(int x, int y, int width, int height) -
240 -
241 Constructs a rectangle with (\a x, \a y) as its top-left corner -
242 and the given \a width and \a height. -
243 -
244 \sa setRect() -
245*/ -
246 -
247 -
248/*! -
249 \fn bool QRect::isNull() const -
250 -
251 Returns true if the rectangle is a null rectangle, otherwise -
252 returns false. -
253 -
254 A null rectangle has both the width and the height set to 0 (i.e., -
255 right() == left() - 1 and bottom() == top() - 1). A null rectangle -
256 is also empty, and hence is not valid. -
257 -
258 \sa isEmpty(), isValid() -
259*/ -
260 -
261/*! -
262 \fn bool QRect::isEmpty() const -
263 -
264 Returns true if the rectangle is empty, otherwise returns false. -
265 -
266 An empty rectangle has a left() > right() or top() > bottom(). An -
267 empty rectangle is not valid (i.e., isEmpty() == !isValid()). -
268 -
269 Use the normalized() function to retrieve a rectangle where the -
270 corners are swapped. -
271 -
272 \sa isNull(), isValid(), normalized() -
273*/ -
274 -
275/*! -
276 \fn bool QRect::isValid() const -
277 -
278 Returns true if the rectangle is valid, otherwise returns false. -
279 -
280 A valid rectangle has a left() < right() and top() < -
281 bottom(). Note that non-trivial operations like intersections are -
282 not defined for invalid rectangles. A valid rectangle is not empty -
283 (i.e., isValid() == !isEmpty()). -
284 -
285 \sa isNull(), isEmpty(), normalized() -
286*/ -
287 -
288 -
289/*! -
290 Returns a normalized rectangle; i.e., a rectangle that has a -
291 non-negative width and height. -
292 -
293 If width() < 0 the function swaps the left and right corners, and -
294 it swaps the top and bottom corners if height() < 0. -
295 -
296 \sa isValid(), isEmpty() -
297*/ -
298 -
299QRect QRect::normalized() const -
300{ -
301 QRect r;
executed (the execution status of this line is deduced): QRect r;
-
302 if (x2 < x1 - 1) { // swap bad x values
evaluated: x2 < x1 - 1
TRUEFALSE
yes
Evaluation Count:880
yes
Evaluation Count:36337
880-36337
303 r.x1 = x2;
executed (the execution status of this line is deduced): r.x1 = x2;
-
304 r.x2 = x1;
executed (the execution status of this line is deduced): r.x2 = x1;
-
305 } else {
executed: }
Execution Count:880
880
306 r.x1 = x1;
executed (the execution status of this line is deduced): r.x1 = x1;
-
307 r.x2 = x2;
executed (the execution status of this line is deduced): r.x2 = x2;
-
308 }
executed: }
Execution Count:36337
36337
309 if (y2 < y1 - 1) { // swap bad y values
evaluated: y2 < y1 - 1
TRUEFALSE
yes
Evaluation Count:407
yes
Evaluation Count:36810
407-36810
310 r.y1 = y2;
executed (the execution status of this line is deduced): r.y1 = y2;
-
311 r.y2 = y1;
executed (the execution status of this line is deduced): r.y2 = y1;
-
312 } else {
executed: }
Execution Count:407
407
313 r.y1 = y1;
executed (the execution status of this line is deduced): r.y1 = y1;
-
314 r.y2 = y2;
executed (the execution status of this line is deduced): r.y2 = y2;
-
315 }
executed: }
Execution Count:36810
36810
316 return r;
executed: return r;
Execution Count:37217
37217
317} -
318 -
319 -
320/*! -
321 \fn int QRect::left() const -
322 -
323 Returns the x-coordinate of the rectangle's left edge. Equivalent -
324 to x(). -
325 -
326 \sa setLeft(), topLeft(), bottomLeft() -
327*/ -
328 -
329/*! -
330 \fn int QRect::top() const -
331 -
332 Returns the y-coordinate of the rectangle's top edge. -
333 Equivalent to y(). -
334 -
335 \sa setTop(), topLeft(), topRight() -
336*/ -
337 -
338/*! -
339 \fn int QRect::right() const -
340 -
341 Returns the x-coordinate of the rectangle's right edge. -
342 -
343 Note that for historical reasons this function returns left() + -
344 width() - 1; use x() + width() to retrieve the true x-coordinate. -
345 -
346 \sa setRight(), topRight(), bottomRight() -
347*/ -
348 -
349/*! -
350 \fn int QRect::bottom() const -
351 -
352 Returns the y-coordinate of the rectangle's bottom edge. -
353 -
354 Note that for historical reasons this function returns top() + -
355 height() - 1; use y() + height() to retrieve the true y-coordinate. -
356 -
357 \sa setBottom(), bottomLeft(), bottomRight() -
358*/ -
359 -
360/*! -
361 \fn int QRect::x() const -
362 -
363 Returns the x-coordinate of the rectangle's left edge. Equivalent to left(). -
364 -
365 \sa setX(), y(), topLeft() -
366*/ -
367 -
368/*! -
369 \fn int QRect::y() const -
370 -
371 Returns the y-coordinate of the rectangle's top edge. Equivalent to top(). -
372 -
373 \sa setY(), x(), topLeft() -
374*/ -
375 -
376/*! -
377 \fn void QRect::setLeft(int x) -
378 -
379 Sets the left edge of the rectangle to the given \a x -
380 coordinate. May change the width, but will never change the right -
381 edge of the rectangle. -
382 -
383 Equivalent to setX(). -
384 -
385 \sa left(), moveLeft() -
386*/ -
387 -
388/*! -
389 \fn void QRect::setTop(int y) -
390 -
391 Sets the top edge of the rectangle to the given \a y -
392 coordinate. May change the height, but will never change the -
393 bottom edge of the rectangle. -
394 -
395 Equivalent to setY(). -
396 -
397 \sa top(), moveTop() -
398*/ -
399 -
400/*! -
401 \fn void QRect::setRight(int x) -
402 -
403 Sets the right edge of the rectangle to the given \a x -
404 coordinate. May change the width, but will never change the left -
405 edge of the rectangle. -
406 -
407 \sa right(), moveRight() -
408*/ -
409 -
410/*! -
411 \fn void QRect::setBottom(int y) -
412 -
413 Sets the bottom edge of the rectangle to the given \a y -
414 coordinate. May change the height, but will never change the top -
415 edge of the rectangle. -
416 -
417 \sa bottom(), moveBottom(), -
418*/ -
419 -
420/*! -
421 \fn void QRect::setX(int x) -
422 -
423 Sets the left edge of the rectangle to the given \a x -
424 coordinate. May change the width, but will never change the right -
425 edge of the rectangle. -
426 -
427 Equivalent to setLeft(). -
428 -
429 \sa x(), setY(), setTopLeft() -
430*/ -
431 -
432/*! -
433 \fn void QRect::setY(int y) -
434 -
435 Sets the top edge of the rectangle to the given \a y -
436 coordinate. May change the height, but will never change the -
437 bottom edge of the rectangle. -
438 -
439 Equivalent to setTop(). -
440 -
441 \sa y(), setX(), setTopLeft() -
442*/ -
443 -
444/*! -
445 \fn void QRect::setTopLeft(const QPoint &position) -
446 -
447 Set the top-left corner of the rectangle to the given \a -
448 position. May change the size, but will never change the -
449 bottom-right corner of the rectangle. -
450 -
451 \sa topLeft(), moveTopLeft() -
452*/ -
453 -
454/*! -
455 \fn void QRect::setBottomRight(const QPoint &position) -
456 -
457 Set the bottom-right corner of the rectangle to the given \a -
458 position. May change the size, but will never change the -
459 top-left corner of the rectangle. -
460 -
461 \sa bottomRight(), moveBottomRight() -
462*/ -
463 -
464/*! -
465 \fn void QRect::setTopRight(const QPoint &position) -
466 -
467 Set the top-right corner of the rectangle to the given \a -
468 position. May change the size, but will never change the -
469 bottom-left corner of the rectangle. -
470 -
471 \sa topRight(), moveTopRight() -
472*/ -
473 -
474/*! -
475 \fn void QRect::setBottomLeft(const QPoint &position) -
476 -
477 Set the bottom-left corner of the rectangle to the given \a -
478 position. May change the size, but will never change the -
479 top-right corner of the rectangle. -
480 -
481 \sa bottomLeft(), moveBottomLeft() -
482*/ -
483 -
484/*! -
485 \fn QPoint QRect::topLeft() const -
486 -
487 Returns the position of the rectangle's top-left corner. -
488 -
489 \sa setTopLeft(), top(), left() -
490*/ -
491 -
492/*! -
493 \fn QPoint QRect::bottomRight() const -
494 -
495 Returns the position of the rectangle's bottom-right corner. -
496 -
497 Note that for historical reasons this function returns -
498 QPoint(left() + width() -1, top() + height() - 1). -
499 -
500 \sa setBottomRight(), bottom(), right() -
501*/ -
502 -
503/*! -
504 \fn QPoint QRect::topRight() const -
505 -
506 Returns the position of the rectangle's top-right corner. -
507 -
508 Note that for historical reasons this function returns -
509 QPoint(left() + width() -1, top()). -
510 -
511 \sa setTopRight(), top(), right() -
512*/ -
513 -
514/*! -
515 \fn QPoint QRect::bottomLeft() const -
516 -
517 Returns the position of the rectangle's bottom-left corner. Note -
518 that for historical reasons this function returns QPoint(left(), -
519 top() + height() - 1). -
520 -
521 \sa setBottomLeft(), bottom(), left() -
522*/ -
523 -
524/*! -
525 \fn QPoint QRect::center() const -
526 -
527 Returns the center point of the rectangle. -
528 -
529 \sa moveCenter() -
530*/ -
531 -
532 -
533/*! -
534 \fn void QRect::getRect(int *x, int *y, int *width, int *height) const -
535 -
536 Extracts the position of the rectangle's top-left corner to *\a x -
537 and *\a y, and its dimensions to *\a width and *\a height. -
538 -
539 \sa setRect(), getCoords() -
540*/ -
541 -
542 -
543/*! -
544 \fn void QRect::getCoords(int *x1, int *y1, int *x2, int *y2) const -
545 -
546 Extracts the position of the rectangle's top-left corner to *\a x1 -
547 and *\a y1, and the position of the bottom-right corner to *\a x2 -
548 and *\a y2. -
549 -
550 \sa setCoords(), getRect() -
551*/ -
552 -
553/*! -
554 \fn void QRect::moveLeft(int x) -
555 -
556 Moves the rectangle horizontally, leaving the rectangle's left -
557 edge at the given \a x coordinate. The rectangle's size is -
558 unchanged. -
559 -
560 \sa left(), setLeft(), moveRight() -
561*/ -
562 -
563/*! -
564 \fn void QRect::moveTop(int y) -
565 -
566 Moves the rectangle vertically, leaving the rectangle's top edge -
567 at the given \a y coordinate. The rectangle's size is unchanged. -
568 -
569 \sa top(), setTop(), moveBottom() -
570*/ -
571 -
572 -
573/*! -
574 \fn void QRect::moveRight(int x) -
575 -
576 Moves the rectangle horizontally, leaving the rectangle's right -
577 edge at the given \a x coordinate. The rectangle's size is -
578 unchanged. -
579 -
580 \sa right(), setRight(), moveLeft() -
581*/ -
582 -
583 -
584/*! -
585 \fn void QRect::moveBottom(int y) -
586 -
587 Moves the rectangle vertically, leaving the rectangle's bottom -
588 edge at the given \a y coordinate. The rectangle's size is -
589 unchanged. -
590 -
591 \sa bottom(), setBottom(), moveTop() -
592*/ -
593 -
594 -
595/*! -
596 \fn void QRect::moveTopLeft(const QPoint &position) -
597 -
598 Moves the rectangle, leaving the top-left corner at the given \a -
599 position. The rectangle's size is unchanged. -
600 -
601 \sa setTopLeft(), moveTop(), moveLeft() -
602*/ -
603 -
604 -
605/*! -
606 \fn void QRect::moveBottomRight(const QPoint &position) -
607 -
608 Moves the rectangle, leaving the bottom-right corner at the given -
609 \a position. The rectangle's size is unchanged. -
610 -
611 \sa setBottomRight(), moveRight(), moveBottom() -
612*/ -
613 -
614 -
615/*! -
616 \fn void QRect::moveTopRight(const QPoint &position) -
617 -
618 Moves the rectangle, leaving the top-right corner at the given \a -
619 position. The rectangle's size is unchanged. -
620 -
621 \sa setTopRight(), moveTop(), moveRight() -
622*/ -
623 -
624 -
625/*! -
626 \fn void QRect::moveBottomLeft(const QPoint &position) -
627 -
628 Moves the rectangle, leaving the bottom-left corner at the given -
629 \a position. The rectangle's size is unchanged. -
630 -
631 \sa setBottomLeft(), moveBottom(), moveLeft() -
632*/ -
633 -
634 -
635/*! -
636 \fn void QRect::moveCenter(const QPoint &position) -
637 -
638 Moves the rectangle, leaving the center point at the given \a -
639 position. The rectangle's size is unchanged. -
640 -
641 \sa center() -
642*/ -
643 -
644/*! -
645 \fn void QRect::moveTo(int x, int y) -
646 -
647 Moves the rectangle, leaving the top-left corner at the given -
648 position (\a x, \a y). The rectangle's size is unchanged. -
649 -
650 \sa translate(), moveTopLeft() -
651*/ -
652 -
653/*! -
654 \fn void QRect::moveTo(const QPoint &position) -
655 -
656 Moves the rectangle, leaving the top-left corner at the given \a -
657 position. -
658*/ -
659 -
660/*! -
661 \fn void QRect::translate(int dx, int dy) -
662 -
663 Moves the rectangle \a dx along the x axis and \a dy along the y -
664 axis, relative to the current position. Positive values move the -
665 rectangle to the right and down. -
666 -
667 \sa moveTopLeft(), moveTo(), translated() -
668*/ -
669 -
670 -
671/*! -
672 \fn void QRect::translate(const QPoint &offset) -
673 \overload -
674 -
675 Moves the rectangle \a{offset}.\l{QPoint::x()}{x()} along the x -
676 axis and \a{offset}.\l{QPoint::y()}{y()} along the y axis, -
677 relative to the current position. -
678*/ -
679 -
680 -
681/*! -
682 \fn QRect QRect::translated(int dx, int dy) const -
683 -
684 Returns a copy of the rectangle that is translated \a dx along the -
685 x axis and \a dy along the y axis, relative to the current -
686 position. Positive values move the rectangle to the right and -
687 down. -
688 -
689 \sa translate() -
690 -
691*/ -
692 -
693 -
694/*! -
695 \fn QRect QRect::translated(const QPoint &offset) const -
696 -
697 \overload -
698 -
699 Returns a copy of the rectangle that is translated -
700 \a{offset}.\l{QPoint::x()}{x()} along the x axis and -
701 \a{offset}.\l{QPoint::y()}{y()} along the y axis, relative to the -
702 current position. -
703*/ -
704 -
705 -
706/*! -
707 \fn void QRect::setRect(int x, int y, int width, int height) -
708 -
709 Sets the coordinates of the rectangle's top-left corner to (\a{x}, -
710 \a{y}), and its size to the given \a width and \a height. -
711 -
712 \sa getRect(), setCoords() -
713*/ -
714 -
715 -
716/*! -
717 \fn void QRect::setCoords(int x1, int y1, int x2, int y2) -
718 -
719 Sets the coordinates of the rectangle's top-left corner to (\a x1, -
720 \a y1), and the coordinates of its bottom-right corner to (\a x2, -
721 \a y2). -
722 -
723 \sa getCoords(), setRect() -
724*/ -
725 -
726 -
727/*! \fn QRect QRect::adjusted(int dx1, int dy1, int dx2, int dy2) const -
728 -
729 Returns a new rectangle with \a dx1, \a dy1, \a dx2 and \a dy2 -
730 added respectively to the existing coordinates of this rectangle. -
731 -
732 \sa adjust() -
733*/ -
734 -
735/*! \fn void QRect::adjust(int dx1, int dy1, int dx2, int dy2) -
736 -
737 Adds \a dx1, \a dy1, \a dx2 and \a dy2 respectively to the -
738 existing coordinates of the rectangle. -
739 -
740 \sa adjusted(), setRect() -
741*/ -
742 -
743/*! -
744 \fn QSize QRect::size() const -
745 -
746 Returns the size of the rectangle. -
747 -
748 \sa setSize(), width(), height() -
749*/ -
750 -
751/*! -
752 \fn int QRect::width() const -
753 -
754 Returns the width of the rectangle. -
755 -
756 \sa setWidth(), height(), size() -
757*/ -
758 -
759/*! -
760 \fn int QRect::height() const -
761 -
762 Returns the height of the rectangle. -
763 -
764 \sa setHeight(), width(), size() -
765*/ -
766 -
767/*! -
768 \fn void QRect::setWidth(int width) -
769 -
770 Sets the width of the rectangle to the given \a width. The right -
771 edge is changed, but not the left one. -
772 -
773 \sa width(), setSize() -
774*/ -
775 -
776 -
777/*! -
778 \fn void QRect::setHeight(int height) -
779 -
780 Sets the height of the rectangle to the given \a height. The bottom -
781 edge is changed, but not the top one. -
782 -
783 \sa height(), setSize() -
784*/ -
785 -
786 -
787/*! -
788 \fn void QRect::setSize(const QSize &size) -
789 -
790 Sets the size of the rectangle to the given \a size. The top-left -
791 corner is not moved. -
792 -
793 \sa size(), setWidth(), setHeight() -
794*/ -
795 -
796 -
797/*! -
798 \fn bool QRect::contains(const QPoint &point, bool proper) const -
799 -
800 Returns true if the given \a point is inside or on the edge of -
801 the rectangle, otherwise returns false. If \a proper is true, this -
802 function only returns true if the given \a point is \e inside the -
803 rectangle (i.e., not on the edge). -
804 -
805 \sa intersects() -
806*/ -
807 -
808bool QRect::contains(const QPoint &p, bool proper) const -
809{ -
810 int l, r;
executed (the execution status of this line is deduced): int l, r;
-
811 if (x2 < x1 - 1) {
evaluated: x2 < x1 - 1
TRUEFALSE
yes
Evaluation Count:24
yes
Evaluation Count:4936662
24-4936662
812 l = x2;
executed (the execution status of this line is deduced): l = x2;
-
813 r = x1;
executed (the execution status of this line is deduced): r = x1;
-
814 } else {
executed: }
Execution Count:24
24
815 l = x1;
executed (the execution status of this line is deduced): l = x1;
-
816 r = x2;
executed (the execution status of this line is deduced): r = x2;
-
817 }
executed: }
Execution Count:4936662
4936662
818 if (proper) {
evaluated: proper
TRUEFALSE
yes
Evaluation Count:27
yes
Evaluation Count:4936659
27-4936659
819 if (p.x() <= l || p.x() >= r)
evaluated: p.x() <= l
TRUEFALSE
yes
Evaluation Count:7
yes
Evaluation Count:20
evaluated: p.x() >= r
TRUEFALSE
yes
Evaluation Count:11
yes
Evaluation Count:9
7-20
820 return false;
executed: return false;
Execution Count:18
18
821 } else {
executed: }
Execution Count:9
9
822 if (p.x() < l || p.x() > r)
evaluated: p.x() < l
TRUEFALSE
yes
Evaluation Count:181877
yes
Evaluation Count:4754782
evaluated: p.x() > r
TRUEFALSE
yes
Evaluation Count:1316123
yes
Evaluation Count:3438659
181877-4754782
823 return false;
executed: return false;
Execution Count:1498000
1498000
824 }
executed: }
Execution Count:3438659
3438659
825 int t, b;
executed (the execution status of this line is deduced): int t, b;
-
826 if (y2 < y1 - 1) {
evaluated: y2 < y1 - 1
TRUEFALSE
yes
Evaluation Count:14
yes
Evaluation Count:3438654
14-3438654
827 t = y2;
executed (the execution status of this line is deduced): t = y2;
-
828 b = y1;
executed (the execution status of this line is deduced): b = y1;
-
829 } else {
executed: }
Execution Count:14
14
830 t = y1;
executed (the execution status of this line is deduced): t = y1;
-
831 b = y2;
executed (the execution status of this line is deduced): b = y2;
-
832 }
executed: }
Execution Count:3438654
3438654
833 if (proper) {
evaluated: proper
TRUEFALSE
yes
Evaluation Count:9
yes
Evaluation Count:3438659
9-3438659
834 if (p.y() <= t || p.y() >= b)
evaluated: p.y() <= t
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:6
partially evaluated: p.y() >= b
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:6
0-6
835 return false;
executed: return false;
Execution Count:3
3
836 } else {
executed: }
Execution Count:6
6
837 if (p.y() < t || p.y() > b)
evaluated: p.y() < t
TRUEFALSE
yes
Evaluation Count:256170
yes
Evaluation Count:3182489
evaluated: p.y() > b
TRUEFALSE
yes
Evaluation Count:2915712
yes
Evaluation Count:266777
256170-3182489
838 return false;
executed: return false;
Execution Count:3171882
3171882
839 }
executed: }
Execution Count:266777
266777
840 return true;
executed: return true;
Execution Count:266783
266783
841} -
842 -
843 -
844/*! -
845 \fn bool QRect::contains(int x, int y, bool proper) const -
846 \overload -
847 -
848 Returns true if the point (\a x, \a y) is inside or on the edge of -
849 the rectangle, otherwise returns false. If \a proper is true, this -
850 function only returns true if the point is entirely inside the -
851 rectangle(not on the edge). -
852*/ -
853 -
854/*! -
855 \fn bool QRect::contains(int x, int y) const -
856 \overload -
857 -
858 Returns true if the point (\a x, \a y) is inside this rectangle, -
859 otherwise returns false. -
860*/ -
861 -
862/*! -
863 \fn bool QRect::contains(const QRect &rectangle, bool proper) const -
864 \overload -
865 -
866 Returns true if the given \a rectangle is inside this rectangle. -
867 otherwise returns false. If \a proper is true, this function only -
868 returns true if the \a rectangle is entirely inside this -
869 rectangle (not on the edge). -
870*/ -
871 -
872bool QRect::contains(const QRect &r, bool proper) const -
873{ -
874 if (isNull() || r.isNull())
evaluated: isNull()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:8005
evaluated: r.isNull()
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:8002
2-8005
875 return false;
executed: return false;
Execution Count:5
5
876 -
877 int l1 = x1;
executed (the execution status of this line is deduced): int l1 = x1;
-
878 int r1 = x1;
executed (the execution status of this line is deduced): int r1 = x1;
-
879 if (x2 - x1 + 1 < 0)
evaluated: x2 - x1 + 1 < 0
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:7998
4-7998
880 l1 = x2;
executed: l1 = x2;
Execution Count:4
4
881 else -
882 r1 = x2;
executed: r1 = x2;
Execution Count:7998
7998
883 -
884 int l2 = r.x1;
executed (the execution status of this line is deduced): int l2 = r.x1;
-
885 int r2 = r.x1;
executed (the execution status of this line is deduced): int r2 = r.x1;
-
886 if (r.x2 - r.x1 + 1 < 0)
evaluated: r.x2 - r.x1 + 1 < 0
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:7998
4-7998
887 l2 = r.x2;
executed: l2 = r.x2;
Execution Count:4
4
888 else -
889 r2 = r.x2;
executed: r2 = r.x2;
Execution Count:7998
7998
890 -
891 if (proper) {
partially evaluated: proper
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:8002
0-8002
892 if (l2 <= l1 || r2 >= r1)
never evaluated: l2 <= l1
never evaluated: r2 >= r1
0
893 return false;
never executed: return false;
0
894 } else {
never executed: }
0
895 if (l2 < l1 || r2 > r1)
evaluated: l2 < l1
TRUEFALSE
yes
Evaluation Count:141
yes
Evaluation Count:7861
evaluated: r2 > r1
TRUEFALSE
yes
Evaluation Count:1917
yes
Evaluation Count:5944
141-7861
896 return false;
executed: return false;
Execution Count:2058
2058
897 }
executed: }
Execution Count:5944
5944
898 -
899 int t1 = y1;
executed (the execution status of this line is deduced): int t1 = y1;
-
900 int b1 = y1;
executed (the execution status of this line is deduced): int b1 = y1;
-
901 if (y2 - y1 + 1 < 0)
evaluated: y2 - y1 + 1 < 0
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:5942
2-5942
902 t1 = y2;
executed: t1 = y2;
Execution Count:2
2
903 else -
904 b1 = y2;
executed: b1 = y2;
Execution Count:5942
5942
905 -
906 int t2 = r.y1;
executed (the execution status of this line is deduced): int t2 = r.y1;
-
907 int b2 = r.y1;
executed (the execution status of this line is deduced): int b2 = r.y1;
-
908 if (r.y2 - r.y1 + 1 < 0)
evaluated: r.y2 - r.y1 + 1 < 0
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:5942
2-5942
909 t2 = r.y2;
executed: t2 = r.y2;
Execution Count:2
2
910 else -
911 b2 = r.y2;
executed: b2 = r.y2;
Execution Count:5942
5942
912 -
913 if (proper) {
partially evaluated: proper
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:5944
0-5944
914 if (t2 <= t1 || b2 >= b1)
never evaluated: t2 <= t1
never evaluated: b2 >= b1
0
915 return false;
never executed: return false;
0
916 } else {
never executed: }
0
917 if (t2 < t1 || b2 > b1)
evaluated: t2 < t1
TRUEFALSE
yes
Evaluation Count:92
yes
Evaluation Count:5852
evaluated: b2 > b1
TRUEFALSE
yes
Evaluation Count:1282
yes
Evaluation Count:4570
92-5852
918 return false;
executed: return false;
Execution Count:1374
1374
919 }
executed: }
Execution Count:4570
4570
920 -
921 return true;
executed: return true;
Execution Count:4570
4570
922} -
923 -
924/*! -
925 \fn QRect& QRect::operator|=(const QRect &rectangle) -
926 -
927 Unites this rectangle with the given \a rectangle. -
928 -
929 \sa united(), operator|() -
930*/ -
931 -
932/*! -
933 \fn QRect& QRect::operator&=(const QRect &rectangle) -
934 -
935 Intersects this rectangle with the given \a rectangle. -
936 -
937 \sa intersected(), operator&() -
938*/ -
939 -
940 -
941/*! -
942 \fn QRect QRect::operator|(const QRect &rectangle) const -
943 -
944 Returns the bounding rectangle of this rectangle and the given \a -
945 rectangle. -
946 -
947 \sa operator|=(), united() -
948*/ -
949 -
950QRect QRect::operator|(const QRect &r) const -
951{ -
952 if (isNull())
evaluated: isNull()
TRUEFALSE
yes
Evaluation Count:1170
yes
Evaluation Count:313122
1170-313122
953 return r;
executed: return r;
Execution Count:1170
1170
954 if (r.isNull())
evaluated: r.isNull()
TRUEFALSE
yes
Evaluation Count:155022
yes
Evaluation Count:158100
155022-158100
955 return *this;
executed: return *this;
Execution Count:155022
155022
956 -
957 int l1 = x1;
executed (the execution status of this line is deduced): int l1 = x1;
-
958 int r1 = x1;
executed (the execution status of this line is deduced): int r1 = x1;
-
959 if (x2 - x1 + 1 < 0)
evaluated: x2 - x1 + 1 < 0
TRUEFALSE
yes
Evaluation Count:46
yes
Evaluation Count:158054
46-158054
960 l1 = x2;
executed: l1 = x2;
Execution Count:46
46
961 else -
962 r1 = x2;
executed: r1 = x2;
Execution Count:158054
158054
963 -
964 int l2 = r.x1;
executed (the execution status of this line is deduced): int l2 = r.x1;
-
965 int r2 = r.x1;
executed (the execution status of this line is deduced): int r2 = r.x1;
-
966 if (r.x2 - r.x1 + 1 < 0)
evaluated: r.x2 - r.x1 + 1 < 0
TRUEFALSE
yes
Evaluation Count:136
yes
Evaluation Count:157964
136-157964
967 l2 = r.x2;
executed: l2 = r.x2;
Execution Count:136
136
968 else -
969 r2 = r.x2;
executed: r2 = r.x2;
Execution Count:157964
157964
970 -
971 int t1 = y1;
executed (the execution status of this line is deduced): int t1 = y1;
-
972 int b1 = y1;
executed (the execution status of this line is deduced): int b1 = y1;
-
973 if (y2 - y1 + 1 < 0)
evaluated: y2 - y1 + 1 < 0
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:158096
4-158096
974 t1 = y2;
executed: t1 = y2;
Execution Count:4
4
975 else -
976 b1 = y2;
executed: b1 = y2;
Execution Count:158096
158096
977 -
978 int t2 = r.y1;
executed (the execution status of this line is deduced): int t2 = r.y1;
-
979 int b2 = r.y1;
executed (the execution status of this line is deduced): int b2 = r.y1;
-
980 if (r.y2 - r.y1 + 1 < 0)
evaluated: r.y2 - r.y1 + 1 < 0
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:158096
4-158096
981 t2 = r.y2;
executed: t2 = r.y2;
Execution Count:4
4
982 else -
983 b2 = r.y2;
executed: b2 = r.y2;
Execution Count:158096
158096
984 -
985 QRect tmp;
executed (the execution status of this line is deduced): QRect tmp;
-
986 tmp.x1 = qMin(l1, l2);
executed (the execution status of this line is deduced): tmp.x1 = qMin(l1, l2);
-
987 tmp.x2 = qMax(r1, r2);
executed (the execution status of this line is deduced): tmp.x2 = qMax(r1, r2);
-
988 tmp.y1 = qMin(t1, t2);
executed (the execution status of this line is deduced): tmp.y1 = qMin(t1, t2);
-
989 tmp.y2 = qMax(b1, b2);
executed (the execution status of this line is deduced): tmp.y2 = qMax(b1, b2);
-
990 return tmp;
executed: return tmp;
Execution Count:158100
158100
991} -
992 -
993/*! -
994 \fn QRect QRect::unite(const QRect &rectangle) const -
995 \obsolete -
996 -
997 Use united(\a rectangle) instead. -
998*/ -
999 -
1000/*! -
1001 \fn QRect QRect::united(const QRect &rectangle) const -
1002 \since 4.2 -
1003 -
1004 Returns the bounding rectangle of this rectangle and the given \a rectangle. -
1005 -
1006 \image qrect-unite.png -
1007 -
1008 \sa intersected() -
1009*/ -
1010 -
1011 -
1012/*! -
1013 \fn QRect QRect::operator&(const QRect &rectangle) const -
1014 -
1015 Returns the intersection of this rectangle and the given \a -
1016 rectangle. Returns an empty rectangle if there is no intersection. -
1017 -
1018 \sa operator&=(), intersected() -
1019*/ -
1020 -
1021QRect QRect::operator&(const QRect &r) const -
1022{ -
1023 if (isNull() || r.isNull())
evaluated: isNull()
TRUEFALSE
yes
Evaluation Count:241
yes
Evaluation Count:280991
evaluated: r.isNull()
TRUEFALSE
yes
Evaluation Count:250
yes
Evaluation Count:280741
241-280991
1024 return QRect();
executed: return QRect();
Execution Count:491
491
1025 -
1026 int l1 = x1;
executed (the execution status of this line is deduced): int l1 = x1;
-
1027 int r1 = x1;
executed (the execution status of this line is deduced): int r1 = x1;
-
1028 if (x2 - x1 + 1 < 0)
evaluated: x2 - x1 + 1 < 0
TRUEFALSE
yes
Evaluation Count:10
yes
Evaluation Count:280731
10-280731
1029 l1 = x2;
executed: l1 = x2;
Execution Count:10
10
1030 else -
1031 r1 = x2;
executed: r1 = x2;
Execution Count:280731
280731
1032 -
1033 int l2 = r.x1;
executed (the execution status of this line is deduced): int l2 = r.x1;
-
1034 int r2 = r.x1;
executed (the execution status of this line is deduced): int r2 = r.x1;
-
1035 if (r.x2 - r.x1 + 1 < 0)
evaluated: r.x2 - r.x1 + 1 < 0
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:280737
4-280737
1036 l2 = r.x2;
executed: l2 = r.x2;
Execution Count:4
4
1037 else -
1038 r2 = r.x2;
executed: r2 = r.x2;
Execution Count:280737
280737
1039 -
1040 if (l1 > r2 || l2 > r1)
evaluated: l1 > r2
TRUEFALSE
yes
Evaluation Count:7097
yes
Evaluation Count:273644
evaluated: l2 > r1
TRUEFALSE
yes
Evaluation Count:3274
yes
Evaluation Count:270370
3274-273644
1041 return QRect();
executed: return QRect();
Execution Count:10371
10371
1042 -
1043 int t1 = y1;
executed (the execution status of this line is deduced): int t1 = y1;
-
1044 int b1 = y1;
executed (the execution status of this line is deduced): int b1 = y1;
-
1045 if (y2 - y1 + 1 < 0)
evaluated: y2 - y1 + 1 < 0
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:270366
4-270366
1046 t1 = y2;
executed: t1 = y2;
Execution Count:4
4
1047 else -
1048 b1 = y2;
executed: b1 = y2;
Execution Count:270366
270366
1049 -
1050 int t2 = r.y1;
executed (the execution status of this line is deduced): int t2 = r.y1;
-
1051 int b2 = r.y1;
executed (the execution status of this line is deduced): int b2 = r.y1;
-
1052 if (r.y2 - r.y1 + 1 < 0)
evaluated: r.y2 - r.y1 + 1 < 0
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:270367
3-270367
1053 t2 = r.y2;
executed: t2 = r.y2;
Execution Count:3
3
1054 else -
1055 b2 = r.y2;
executed: b2 = r.y2;
Execution Count:270367
270367
1056 -
1057 if (t1 > b2 || t2 > b1)
evaluated: t1 > b2
TRUEFALSE
yes
Evaluation Count:1826
yes
Evaluation Count:268544
evaluated: t2 > b1
TRUEFALSE
yes
Evaluation Count:652
yes
Evaluation Count:267892
652-268544
1058 return QRect();
executed: return QRect();
Execution Count:2478
2478
1059 -
1060 QRect tmp;
executed (the execution status of this line is deduced): QRect tmp;
-
1061 tmp.x1 = qMax(l1, l2);
executed (the execution status of this line is deduced): tmp.x1 = qMax(l1, l2);
-
1062 tmp.x2 = qMin(r1, r2);
executed (the execution status of this line is deduced): tmp.x2 = qMin(r1, r2);
-
1063 tmp.y1 = qMax(t1, t2);
executed (the execution status of this line is deduced): tmp.y1 = qMax(t1, t2);
-
1064 tmp.y2 = qMin(b1, b2);
executed (the execution status of this line is deduced): tmp.y2 = qMin(b1, b2);
-
1065 return tmp;
executed: return tmp;
Execution Count:267892
267892
1066} -
1067 -
1068/*! -
1069 \fn QRect QRect::intersect(const QRect &rectangle) const -
1070 \obsolete -
1071 -
1072 Use intersected(\a rectangle) instead. -
1073*/ -
1074 -
1075/*! -
1076 \fn QRect QRect::intersected(const QRect &rectangle) const -
1077 \since 4.2 -
1078 -
1079 Returns the intersection of this rectangle and the given \a -
1080 rectangle. Note that \c{r.intersected(s)} is equivalent to \c{r & s}. -
1081 -
1082 \image qrect-intersect.png -
1083 -
1084 \sa intersects(), united(), operator&=() -
1085*/ -
1086 -
1087/*! -
1088 \fn bool QRect::intersects(const QRect &rectangle) const -
1089 -
1090 Returns true if this rectangle intersects with the given \a -
1091 rectangle (i.e., there is at least one pixel that is within both -
1092 rectangles), otherwise returns false. -
1093 -
1094 The intersection rectangle can be retrieved using the intersected() -
1095 function. -
1096 -
1097 \sa contains() -
1098*/ -
1099 -
1100bool QRect::intersects(const QRect &r) const -
1101{ -
1102 if (isNull() || r.isNull())
evaluated: isNull()
TRUEFALSE
yes
Evaluation Count:571
yes
Evaluation Count:31163
evaluated: r.isNull()
TRUEFALSE
yes
Evaluation Count:538
yes
Evaluation Count:30625
538-31163
1103 return false;
executed: return false;
Execution Count:1109
1109
1104 -
1105 int l1 = x1;
executed (the execution status of this line is deduced): int l1 = x1;
-
1106 int r1 = x1;
executed (the execution status of this line is deduced): int r1 = x1;
-
1107 if (x2 - x1 + 1 < 0)
evaluated: x2 - x1 + 1 < 0
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:30621
4-30621
1108 l1 = x2;
executed: l1 = x2;
Execution Count:4
4
1109 else -
1110 r1 = x2;
executed: r1 = x2;
Execution Count:30621
30621
1111 -
1112 int l2 = r.x1;
executed (the execution status of this line is deduced): int l2 = r.x1;
-
1113 int r2 = r.x1;
executed (the execution status of this line is deduced): int r2 = r.x1;
-
1114 if (r.x2 - r.x1 + 1 < 0)
evaluated: r.x2 - r.x1 + 1 < 0
TRUEFALSE
yes
Evaluation Count:9
yes
Evaluation Count:30616
9-30616
1115 l2 = r.x2;
executed: l2 = r.x2;
Execution Count:9
9
1116 else -
1117 r2 = r.x2;
executed: r2 = r.x2;
Execution Count:30616
30616
1118 -
1119 if (l1 > r2 || l2 > r1)
evaluated: l1 > r2
TRUEFALSE
yes
Evaluation Count:2407
yes
Evaluation Count:28218
evaluated: l2 > r1
TRUEFALSE
yes
Evaluation Count:429
yes
Evaluation Count:27789
429-28218
1120 return false;
executed: return false;
Execution Count:2836
2836
1121 -
1122 int t1 = y1;
executed (the execution status of this line is deduced): int t1 = y1;
-
1123 int b1 = y1;
executed (the execution status of this line is deduced): int b1 = y1;
-
1124 if (y2 - y1 + 1 < 0)
evaluated: y2 - y1 + 1 < 0
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:27786
3-27786
1125 t1 = y2;
executed: t1 = y2;
Execution Count:3
3
1126 else -
1127 b1 = y2;
executed: b1 = y2;
Execution Count:27786
27786
1128 -
1129 int t2 = r.y1;
executed (the execution status of this line is deduced): int t2 = r.y1;
-
1130 int b2 = r.y1;
executed (the execution status of this line is deduced): int b2 = r.y1;
-
1131 if (r.y2 - r.y1 + 1 < 0)
evaluated: r.y2 - r.y1 + 1 < 0
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:27781
8-27781
1132 t2 = r.y2;
executed: t2 = r.y2;
Execution Count:8
8
1133 else -
1134 b2 = r.y2;
executed: b2 = r.y2;
Execution Count:27781
27781
1135 -
1136 if (t1 > b2 || t2 > b1)
evaluated: t1 > b2
TRUEFALSE
yes
Evaluation Count:258
yes
Evaluation Count:27531
evaluated: t2 > b1
TRUEFALSE
yes
Evaluation Count:175
yes
Evaluation Count:27356
175-27531
1137 return false;
executed: return false;
Execution Count:433
433
1138 -
1139 return true;
executed: return true;
Execution Count:27356
27356
1140} -
1141 -
1142/*! -
1143 \fn bool operator==(const QRect &r1, const QRect &r2) -
1144 \relates QRect -
1145 -
1146 Returns true if the rectangles \a r1 and \a r2 are equal, -
1147 otherwise returns false. -
1148*/ -
1149 -
1150 -
1151/*! -
1152 \fn bool operator!=(const QRect &r1, const QRect &r2) -
1153 \relates QRect -
1154 -
1155 Returns true if the rectangles \a r1 and \a r2 are different, otherwise -
1156 returns false. -
1157*/ -
1158 -
1159 -
1160/***************************************************************************** -
1161 QRect stream functions -
1162 *****************************************************************************/ -
1163#ifndef QT_NO_DATASTREAM -
1164/*! -
1165 \fn QDataStream &operator<<(QDataStream &stream, const QRect &rectangle) -
1166 \relates QRect -
1167 -
1168 Writes the given \a rectangle to the given \a stream, and returns -
1169 a reference to the stream. -
1170 -
1171 \sa {Serializing Qt Data Types} -
1172*/ -
1173 -
1174QDataStream &operator<<(QDataStream &s, const QRect &r) -
1175{ -
1176 if (s.version() == 1)
partially evaluated: s.version() == 1
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:112
0-112
1177 s << (qint16)r.left() << (qint16)r.top()
never executed: s << (qint16)r.left() << (qint16)r.top() << (qint16)r.right() << (qint16)r.bottom();
0
1178 << (qint16)r.right() << (qint16)r.bottom();
never executed: s << (qint16)r.left() << (qint16)r.top() << (qint16)r.right() << (qint16)r.bottom();
0
1179 else -
1180 s << (qint32)r.left() << (qint32)r.top()
executed: s << (qint32)r.left() << (qint32)r.top() << (qint32)r.right() << (qint32)r.bottom();
Execution Count:112
112
1181 << (qint32)r.right() << (qint32)r.bottom();
executed: s << (qint32)r.left() << (qint32)r.top() << (qint32)r.right() << (qint32)r.bottom();
Execution Count:112
112
1182 return s;
executed: return s;
Execution Count:112
112
1183} -
1184 -
1185/*! -
1186 \fn QDataStream &operator>>(QDataStream &stream, QRect &rectangle) -
1187 \relates QRect -
1188 -
1189 Reads a rectangle from the given \a stream into the given \a -
1190 rectangle, and returns a reference to the stream. -
1191 -
1192 \sa {Serializing Qt Data Types} -
1193*/ -
1194 -
1195QDataStream &operator>>(QDataStream &s, QRect &r) -
1196{ -
1197 if (s.version() == 1) {
partially evaluated: s.version() == 1
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:122
0-122
1198 qint16 x1, y1, x2, y2;
never executed (the execution status of this line is deduced): qint16 x1, y1, x2, y2;
-
1199 s >> x1; s >> y1; s >> x2; s >> y2;
never executed (the execution status of this line is deduced): s >> x1; s >> y1; s >> x2; s >> y2;
-
1200 r.setCoords(x1, y1, x2, y2);
never executed (the execution status of this line is deduced): r.setCoords(x1, y1, x2, y2);
-
1201 }
never executed: }
0
1202 else { -
1203 qint32 x1, y1, x2, y2;
executed (the execution status of this line is deduced): qint32 x1, y1, x2, y2;
-
1204 s >> x1; s >> y1; s >> x2; s >> y2;
executed (the execution status of this line is deduced): s >> x1; s >> y1; s >> x2; s >> y2;
-
1205 r.setCoords(x1, y1, x2, y2);
executed (the execution status of this line is deduced): r.setCoords(x1, y1, x2, y2);
-
1206 }
executed: }
Execution Count:122
122
1207 return s;
executed: return s;
Execution Count:122
122
1208} -
1209 -
1210#endif // QT_NO_DATASTREAM -
1211 -
1212 -
1213#ifndef QT_NO_DEBUG_STREAM -
1214QDebug operator<<(QDebug dbg, const QRect &r) { -
1215 dbg.nospace() << "QRect(" << r.x() << ',' << r.y() << ' '
executed (the execution status of this line is deduced): dbg.nospace() << "QRect(" << r.x() << ',' << r.y() << ' '
-
1216 << r.width() << 'x' << r.height() << ')';
executed (the execution status of this line is deduced): << r.width() << 'x' << r.height() << ')';
-
1217 return dbg.space();
executed: return dbg.space();
Execution Count:4
4
1218} -
1219#endif -
1220 -
1221/*! -
1222 \class QRectF -
1223 \inmodule QtCore -
1224 \ingroup painting -
1225 -
1226 \brief The QRectF class defines a rectangle in the plane using floating -
1227 point precision. -
1228 -
1229 A rectangle is normally expressed as an upper-left corner and a -
1230 size. The size (width and height) of a QRectF is always equivalent -
1231 to the mathematical rectangle that forms the basis for its -
1232 rendering. -
1233 -
1234 A QRectF can be constructed with a set of left, top, width and -
1235 height integers, or from a QPoint and a QSize. The following code -
1236 creates two identical rectangles. -
1237 -
1238 \snippet code/src_corelib_tools_qrect.cpp 1 -
1239 -
1240 There is also a third constructor creating a QRectF from a QRect, -
1241 and a corresponding toRect() function that returns a QRect object -
1242 based on the values of this rectangle (note that the coordinates -
1243 in the returned rectangle are rounded to the nearest integer). -
1244 -
1245 The QRectF class provides a collection of functions that return -
1246 the various rectangle coordinates, and enable manipulation of -
1247 these. QRectF also provide functions to move the rectangle -
1248 relative to the various coordinates. In addition there is a -
1249 moveTo() function that moves the rectangle, leaving its top left -
1250 corner at the given coordinates. Alternatively, the translate() -
1251 function moves the rectangle the given offset relative to the -
1252 current position, and the translated() function returns a -
1253 translated copy of this rectangle. -
1254 -
1255 The size() function returns the rectange's dimensions as a -
1256 QSize. The dimensions can also be retrieved separately using the -
1257 width() and height() functions. To manipulate the dimensions use -
1258 the setSize(), setWidth() or setHeight() functions. Alternatively, -
1259 the size can be changed by applying either of the functions -
1260 setting the rectangle coordinates, for example, setBottom() or -
1261 setRight(). -
1262 -
1263 The contains() function tells whether a given point is inside the -
1264 rectangle or not, and the intersects() function returns true if -
1265 this rectangle intersects with a given rectangle (otherwise -
1266 false). The QRectF class also provides the intersected() function -
1267 which returns the intersection rectangle, and the united() function -
1268 which returns the rectangle that encloses the given rectangle and -
1269 this: -
1270 -
1271 \table -
1272 \row -
1273 \li \inlineimage qrect-intersect.png -
1274 \li \inlineimage qrect-unite.png -
1275 \row -
1276 \li intersected() -
1277 \li united() -
1278 \endtable -
1279 -
1280 The isEmpty() function returns true if the rectangle's width or -
1281 height is less than, or equal to, 0. Note that an empty rectangle -
1282 is not valid: The isValid() function returns true if both width -
1283 and height is larger than 0. A null rectangle (isNull() == true) -
1284 on the other hand, has both width and height set to 0. -
1285 -
1286 Note that due to the way QRect and QRectF are defined, an -
1287 empty QRectF is defined in essentially the same way as QRect. -
1288 -
1289 Finally, QRectF objects can be streamed as well as compared. -
1290 -
1291 \tableofcontents -
1292 -
1293 \section1 Rendering -
1294 -
1295 When using an \l {QPainter::Antialiasing}{anti-aliased} painter, -
1296 the boundary line of a QRectF will be rendered symmetrically on both -
1297 sides of the mathematical rectangle's boundary line. But when -
1298 using an aliased painter (the default) other rules apply. -
1299 -
1300 Then, when rendering with a one pixel wide pen the QRectF's boundary -
1301 line will be rendered to the right and below the mathematical -
1302 rectangle's boundary line. -
1303 -
1304 When rendering with a two pixels wide pen the boundary line will -
1305 be split in the middle by the mathematical rectangle. This will be -
1306 the case whenever the pen is set to an even number of pixels, -
1307 while rendering with a pen with an odd number of pixels, the spare -
1308 pixel will be rendered to the right and below the mathematical -
1309 rectangle as in the one pixel case. -
1310 -
1311 \table -
1312 \row -
1313 \li \inlineimage qrect-diagram-zero.png -
1314 \li \inlineimage qrectf-diagram-one.png -
1315 \row -
1316 \li Logical representation -
1317 \li One pixel wide pen -
1318 \row -
1319 \li \inlineimage qrectf-diagram-two.png -
1320 \li \inlineimage qrectf-diagram-three.png -
1321 \row -
1322 \li Two pixel wide pen -
1323 \li Three pixel wide pen -
1324 \endtable -
1325 -
1326 \section1 Coordinates -
1327 -
1328 The QRectF class provides a collection of functions that return -
1329 the various rectangle coordinates, and enable manipulation of -
1330 these. QRectF also provide functions to move the rectangle -
1331 relative to the various coordinates. -
1332 -
1333 For example: the bottom(), setBottom() and moveBottom() functions: -
1334 bottom() returns the y-coordinate of the rectangle's bottom edge, -
1335 setBottom() sets the bottom edge of the rectangle to the given y -
1336 coordinate (it may change the height, but will never change the -
1337 rectangle's top edge) and moveBottom() moves the entire rectangle -
1338 vertically, leaving the rectangle's bottom edge at the given y -
1339 coordinate and its size unchanged. -
1340 -
1341 \image qrectf-coordinates.png -
1342 -
1343 It is also possible to add offsets to this rectangle's coordinates -
1344 using the adjust() function, as well as retrieve a new rectangle -
1345 based on adjustments of the original one using the adjusted() -
1346 function. If either of the width and height is negative, use the -
1347 normalized() function to retrieve a rectangle where the corners -
1348 are swapped. -
1349 -
1350 In addition, QRectF provides the getCoords() function which extracts -
1351 the position of the rectangle's top-left and bottom-right corner, -
1352 and the getRect() function which extracts the rectangle's top-left -
1353 corner, width and height. Use the setCoords() and setRect() -
1354 function to manipulate the rectangle's coordinates and dimensions -
1355 in one go. -
1356 -
1357 \sa QRect, QRegion -
1358*/ -
1359 -
1360/***************************************************************************** -
1361 QRectF member functions -
1362 *****************************************************************************/ -
1363 -
1364/*! -
1365 \fn QRectF::QRectF() -
1366 -
1367 Constructs a null rectangle. -
1368 -
1369 \sa isNull() -
1370*/ -
1371 -
1372/*! -
1373 \fn QRectF::QRectF(const QPointF &topLeft, const QSizeF &size) -
1374 -
1375 Constructs a rectangle with the given \a topLeft corner and the given \a size. -
1376 -
1377 \sa setTopLeft(), setSize() -
1378*/ -
1379 -
1380/*! -
1381 \fn QRectF::QRectF(const QPointF &topLeft, const QPointF &bottomRight) -
1382 \since 4.3 -
1383 -
1384 Constructs a rectangle with the given \a topLeft and \a bottomRight corners. -
1385 -
1386 \sa setTopLeft(), setBottomRight() -
1387*/ -
1388 -
1389/*! -
1390 \fn QRectF::QRectF(qreal x, qreal y, qreal width, qreal height) -
1391 -
1392 Constructs a rectangle with (\a x, \a y) as its top-left corner -
1393 and the given \a width and \a height. -
1394 -
1395 \sa setRect() -
1396*/ -
1397 -
1398/*! -
1399 \fn QRectF::QRectF(const QRect &rectangle) -
1400 -
1401 Constructs a QRectF rectangle from the given QRect \a rectangle. -
1402 -
1403 \sa toRect() -
1404*/ -
1405 -
1406/*! -
1407 \fn bool QRectF::isNull() const -
1408 -
1409 Returns true if the rectangle is a null rectangle, otherwise returns false. -
1410 -
1411 A null rectangle has both the width and the height set to 0. A -
1412 null rectangle is also empty, and hence not valid. -
1413 -
1414 \sa isEmpty(), isValid() -
1415*/ -
1416 -
1417/*! -
1418 \fn bool QRectF::isEmpty() const -
1419 -
1420 Returns true if the rectangle is empty, otherwise returns false. -
1421 -
1422 An empty rectangle has width() <= 0 or height() <= 0. An empty -
1423 rectangle is not valid (i.e., isEmpty() == !isValid()). -
1424 -
1425 Use the normalized() function to retrieve a rectangle where the -
1426 corners are swapped. -
1427 -
1428 \sa isNull(), isValid(), normalized() -
1429*/ -
1430 -
1431/*! -
1432 \fn bool QRectF::isValid() const -
1433 -
1434 Returns true if the rectangle is valid, otherwise returns false. -
1435 -
1436 A valid rectangle has a width() > 0 and height() > 0. Note that -
1437 non-trivial operations like intersections are not defined for -
1438 invalid rectangles. A valid rectangle is not empty (i.e., isValid() -
1439 == !isEmpty()). -
1440 -
1441 \sa isNull(), isEmpty(), normalized() -
1442*/ -
1443 -
1444 -
1445/*! -
1446 Returns a normalized rectangle; i.e., a rectangle that has a -
1447 non-negative width and height. -
1448 -
1449 If width() < 0 the function swaps the left and right corners, and -
1450 it swaps the top and bottom corners if height() < 0. -
1451 -
1452 \sa isValid(), isEmpty() -
1453*/ -
1454 -
1455QRectF QRectF::normalized() const -
1456{ -
1457 QRectF r = *this;
executed (the execution status of this line is deduced): QRectF r = *this;
-
1458 if (r.w < 0) {
evaluated: r.w < 0
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:5189
1-5189
1459 r.xp += r.w;
executed (the execution status of this line is deduced): r.xp += r.w;
-
1460 r.w = -r.w;
executed (the execution status of this line is deduced): r.w = -r.w;
-
1461 }
executed: }
Execution Count:1
1
1462 if (r.h < 0) {
partially evaluated: r.h < 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:5190
0-5190
1463 r.yp += r.h;
never executed (the execution status of this line is deduced): r.yp += r.h;
-
1464 r.h = -r.h;
never executed (the execution status of this line is deduced): r.h = -r.h;
-
1465 }
never executed: }
0
1466 return r;
executed: return r;
Execution Count:5190
5190
1467} -
1468 -
1469/*! -
1470 \fn qreal QRectF::x() const -
1471 -
1472 Returns the x-coordinate of the rectangle's left edge. Equivalent -
1473 to left(). -
1474 -
1475 -
1476 \sa setX(), y(), topLeft() -
1477*/ -
1478 -
1479/*! -
1480 \fn qreal QRectF::y() const -
1481 -
1482 Returns the y-coordinate of the rectangle's top edge. Equivalent -
1483 to top(). -
1484 -
1485 \sa setY(), x(), topLeft() -
1486*/ -
1487 -
1488 -
1489/*! -
1490 \fn void QRectF::setLeft(qreal x) -
1491 -
1492 Sets the left edge of the rectangle to the given \a x -
1493 coordinate. May change the width, but will never change the right -
1494 edge of the rectangle. -
1495 -
1496 Equivalent to setX(). -
1497 -
1498 \sa left(), moveLeft() -
1499*/ -
1500 -
1501/*! -
1502 \fn void QRectF::setTop(qreal y) -
1503 -
1504 Sets the top edge of the rectangle to the given \a y coordinate. May -
1505 change the height, but will never change the bottom edge of the -
1506 rectangle. -
1507 -
1508 Equivalent to setY(). -
1509 -
1510 \sa top(), moveTop() -
1511*/ -
1512 -
1513/*! -
1514 \fn void QRectF::setRight(qreal x) -
1515 -
1516 Sets the right edge of the rectangle to the given \a x -
1517 coordinate. May change the width, but will never change the left -
1518 edge of the rectangle. -
1519 -
1520 \sa right(), moveRight() -
1521*/ -
1522 -
1523/*! -
1524 \fn void QRectF::setBottom(qreal y) -
1525 -
1526 Sets the bottom edge of the rectangle to the given \a y -
1527 coordinate. May change the height, but will never change the top -
1528 edge of the rectangle. -
1529 -
1530 \sa bottom(), moveBottom() -
1531*/ -
1532 -
1533/*! -
1534 \fn void QRectF::setX(qreal x) -
1535 -
1536 Sets the left edge of the rectangle to the given \a x -
1537 coordinate. May change the width, but will never change the right -
1538 edge of the rectangle. -
1539 -
1540 Equivalent to setLeft(). -
1541 -
1542 \sa x(), setY(), setTopLeft() -
1543*/ -
1544 -
1545/*! -
1546 \fn void QRectF::setY(qreal y) -
1547 -
1548 Sets the top edge of the rectangle to the given \a y -
1549 coordinate. May change the height, but will never change the -
1550 bottom edge of the rectangle. -
1551 -
1552 Equivalent to setTop(). -
1553 -
1554 \sa y(), setX(), setTopLeft() -
1555*/ -
1556 -
1557/*! -
1558 \fn void QRectF::setTopLeft(const QPointF &position) -
1559 -
1560 Set the top-left corner of the rectangle to the given \a -
1561 position. May change the size, but will never change the -
1562 bottom-right corner of the rectangle. -
1563 -
1564 \sa topLeft(), moveTopLeft() -
1565*/ -
1566 -
1567/*! -
1568 \fn void QRectF::setBottomRight(const QPointF &position) -
1569 -
1570 Set the bottom-right corner of the rectangle to the given \a -
1571 position. May change the size, but will never change the -
1572 top-left corner of the rectangle. -
1573 -
1574 \sa bottomRight(), moveBottomRight() -
1575*/ -
1576 -
1577/*! -
1578 \fn void QRectF::setTopRight(const QPointF &position) -
1579 -
1580 Set the top-right corner of the rectangle to the given \a -
1581 position. May change the size, but will never change the -
1582 bottom-left corner of the rectangle. -
1583 -
1584 \sa topRight(), moveTopRight() -
1585*/ -
1586 -
1587/*! -
1588 \fn void QRectF::setBottomLeft(const QPointF &position) -
1589 -
1590 Set the bottom-left corner of the rectangle to the given \a -
1591 position. May change the size, but will never change the -
1592 top-right corner of the rectangle. -
1593 -
1594 \sa bottomLeft(), moveBottomLeft() -
1595*/ -
1596 -
1597/*! -
1598 \fn QPointF QRectF::center() const -
1599 -
1600 Returns the center point of the rectangle. -
1601 -
1602 \sa moveCenter() -
1603*/ -
1604 -
1605 -
1606/*! -
1607 \fn void QRectF::getRect(qreal *x, qreal *y, qreal *width, qreal *height) const -
1608 -
1609 Extracts the position of the rectangle's top-left corner to *\a x and -
1610 *\a y, and its dimensions to *\a width and *\a height. -
1611 -
1612 \sa setRect(), getCoords() -
1613*/ -
1614 -
1615 -
1616/*! -
1617 \fn void QRectF::getCoords(qreal *x1, qreal *y1, qreal *x2, qreal *y2) const -
1618 -
1619 Extracts the position of the rectangle's top-left corner to *\a x1 -
1620 and *\a y1, and the position of the bottom-right corner to *\a x2 and -
1621 *\a y2. -
1622 -
1623 \sa setCoords(), getRect() -
1624*/ -
1625 -
1626/*! -
1627 \fn void QRectF::moveLeft(qreal x) -
1628 -
1629 Moves the rectangle horizontally, leaving the rectangle's left -
1630 edge at the given \a x coordinate. The rectangle's size is -
1631 unchanged. -
1632 -
1633 \sa left(), setLeft(), moveRight() -
1634*/ -
1635 -
1636/*! -
1637 \fn void QRectF::moveTop(qreal y) -
1638 -
1639 Moves the rectangle vertically, leaving the rectangle's top line -
1640 at the given \a y coordinate. The rectangle's size is unchanged. -
1641 -
1642 \sa top(), setTop(), moveBottom() -
1643*/ -
1644 -
1645 -
1646/*! -
1647 \fn void QRectF::moveRight(qreal x) -
1648 -
1649 Moves the rectangle horizontally, leaving the rectangle's right -
1650 edge at the given \a x coordinate. The rectangle's size is -
1651 unchanged. -
1652 -
1653 \sa right(), setRight(), moveLeft() -
1654*/ -
1655 -
1656 -
1657/*! -
1658 \fn void QRectF::moveBottom(qreal y) -
1659 -
1660 Moves the rectangle vertically, leaving the rectangle's bottom -
1661 edge at the given \a y coordinate. The rectangle's size is -
1662 unchanged. -
1663 -
1664 \sa bottom(), setBottom(), moveTop() -
1665*/ -
1666 -
1667 -
1668/*! -
1669 \fn void QRectF::moveTopLeft(const QPointF &position) -
1670 -
1671 Moves the rectangle, leaving the top-left corner at the given \a -
1672 position. The rectangle's size is unchanged. -
1673 -
1674 \sa setTopLeft(), moveTop(), moveLeft() -
1675*/ -
1676 -
1677 -
1678/*! -
1679 \fn void QRectF::moveBottomRight(const QPointF &position) -
1680 -
1681 Moves the rectangle, leaving the bottom-right corner at the given -
1682 \a position. The rectangle's size is unchanged. -
1683 -
1684 \sa setBottomRight(), moveBottom(), moveRight() -
1685*/ -
1686 -
1687 -
1688/*! -
1689 \fn void QRectF::moveTopRight(const QPointF &position) -
1690 -
1691 Moves the rectangle, leaving the top-right corner at the given -
1692 \a position. The rectangle's size is unchanged. -
1693 -
1694 \sa setTopRight(), moveTop(), moveRight() -
1695*/ -
1696 -
1697 -
1698/*! -
1699 \fn void QRectF::moveBottomLeft(const QPointF &position) -
1700 -
1701 Moves the rectangle, leaving the bottom-left corner at the given -
1702 \a position. The rectangle's size is unchanged. -
1703 -
1704 \sa setBottomLeft(), moveBottom(), moveLeft() -
1705*/ -
1706 -
1707 -
1708/*! -
1709 \fn void QRectF::moveTo(qreal x, qreal y) -
1710 -
1711 Moves the rectangle, leaving the top-left corner at the given -
1712 position (\a x, \a y). The rectangle's size is unchanged. -
1713 -
1714 \sa translate(), moveTopLeft() -
1715*/ -
1716 -
1717/*! -
1718 \fn void QRectF::moveTo(const QPointF &position) -
1719 \overload -
1720 -
1721 Moves the rectangle, leaving the top-left corner at the given \a -
1722 position. -
1723*/ -
1724 -
1725/*! -
1726 \fn void QRectF::translate(qreal dx, qreal dy) -
1727 -
1728 Moves the rectangle \a dx along the x-axis and \a dy along the y-axis, -
1729 relative to the current position. Positive values move the rectangle to the -
1730 right and downwards. -
1731 -
1732 \sa moveTopLeft(), moveTo(), translated() -
1733*/ -
1734 -
1735 -
1736/*! -
1737 \fn void QRectF::translate(const QPointF &offset) -
1738 \overload -
1739 -
1740 Moves the rectangle \a{offset}.\l{QPointF::x()}{x()} along the x -
1741 axis and \a{offset}.\l{QPointF::y()}{y()} along the y axis, -
1742 relative to the current position. -
1743*/ -
1744 -
1745 -
1746/*! -
1747 \fn QRectF QRectF::translated(qreal dx, qreal dy) const -
1748 -
1749 Returns a copy of the rectangle that is translated \a dx along the -
1750 x axis and \a dy along the y axis, relative to the current -
1751 position. Positive values move the rectangle to the right and -
1752 down. -
1753 -
1754 \sa translate() -
1755*/ -
1756 -
1757 -
1758/*! -
1759 \fn QRectF QRectF::translated(const QPointF &offset) const -
1760 \overload -
1761 -
1762 Returns a copy of the rectangle that is translated -
1763 \a{offset}.\l{QPointF::x()}{x()} along the x axis and -
1764 \a{offset}.\l{QPointF::y()}{y()} along the y axis, relative to the -
1765 current position. -
1766*/ -
1767 -
1768 -
1769/*! -
1770 \fn void QRectF::setRect(qreal x, qreal y, qreal width, qreal height) -
1771 -
1772 Sets the coordinates of the rectangle's top-left corner to (\a x, -
1773 \a y), and its size to the given \a width and \a height. -
1774 -
1775 \sa getRect(), setCoords() -
1776*/ -
1777 -
1778 -
1779/*! -
1780 \fn void QRectF::setCoords(qreal x1, qreal y1, qreal x2, qreal y2) -
1781 -
1782 Sets the coordinates of the rectangle's top-left corner to (\a x1, -
1783 \a y1), and the coordinates of its bottom-right corner to (\a x2, -
1784 \a y2). -
1785 -
1786 \sa getCoords(), setRect() -
1787*/ -
1788 -
1789/*! -
1790 \fn QRectF QRectF::adjusted(qreal dx1, qreal dy1, qreal dx2, qreal dy2) const -
1791 -
1792 Returns a new rectangle with \a dx1, \a dy1, \a dx2 and \a dy2 -
1793 added respectively to the existing coordinates of this rectangle. -
1794 -
1795 \sa adjust() -
1796*/ -
1797 -
1798/*! \fn void QRectF::adjust(qreal dx1, qreal dy1, qreal dx2, qreal dy2) -
1799 -
1800 Adds \a dx1, \a dy1, \a dx2 and \a dy2 respectively to the -
1801 existing coordinates of the rectangle. -
1802 -
1803 \sa adjusted(), setRect() -
1804*/ -
1805/*! -
1806 \fn QSizeF QRectF::size() const -
1807 -
1808 Returns the size of the rectangle. -
1809 -
1810 \sa setSize(), width(), height() -
1811*/ -
1812 -
1813/*! -
1814 \fn qreal QRectF::width() const -
1815 -
1816 Returns the width of the rectangle. -
1817 -
1818 \sa setWidth(), height(), size() -
1819*/ -
1820 -
1821/*! -
1822 \fn qreal QRectF::height() const -
1823 -
1824 Returns the height of the rectangle. -
1825 -
1826 \sa setHeight(), width(), size() -
1827*/ -
1828 -
1829/*! -
1830 \fn void QRectF::setWidth(qreal width) -
1831 -
1832 Sets the width of the rectangle to the given \a width. The right -
1833 edge is changed, but not the left one. -
1834 -
1835 \sa width(), setSize() -
1836*/ -
1837 -
1838 -
1839/*! -
1840 \fn void QRectF::setHeight(qreal height) -
1841 -
1842 Sets the height of the rectangle to the given \a height. The bottom -
1843 edge is changed, but not the top one. -
1844 -
1845 \sa height(), setSize() -
1846*/ -
1847 -
1848 -
1849/*! -
1850 \fn void QRectF::setSize(const QSizeF &size) -
1851 -
1852 Sets the size of the rectangle to the given \a size. The top-left -
1853 corner is not moved. -
1854 -
1855 \sa size(), setWidth(), setHeight() -
1856*/ -
1857 -
1858 -
1859/*! -
1860 \fn bool QRectF::contains(const QPointF &point) const -
1861 -
1862 Returns true if the given \a point is inside or on the edge of the -
1863 rectangle; otherwise returns false. -
1864 -
1865 \sa intersects() -
1866*/ -
1867 -
1868bool QRectF::contains(const QPointF &p) const -
1869{ -
1870 qreal l = xp;
executed (the execution status of this line is deduced): qreal l = xp;
-
1871 qreal r = xp;
executed (the execution status of this line is deduced): qreal r = xp;
-
1872 if (w < 0)
evaluated: w < 0
TRUEFALSE
yes
Evaluation Count:12
yes
Evaluation Count:3404
12-3404
1873 l += w;
executed: l += w;
Execution Count:12
12
1874 else -
1875 r += w;
executed: r += w;
Execution Count:3404
3404
1876 if (l == r) // null rect
evaluated: l == r
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:3412
4-3412
1877 return false;
executed: return false;
Execution Count:4
4
1878 -
1879 if (p.x() < l || p.x() > r)
evaluated: p.x() < l
TRUEFALSE
yes
Evaluation Count:358
yes
Evaluation Count:3054
evaluated: p.x() > r
TRUEFALSE
yes
Evaluation Count:388
yes
Evaluation Count:2666
358-3054
1880 return false;
executed: return false;
Execution Count:746
746
1881 -
1882 qreal t = yp;
executed (the execution status of this line is deduced): qreal t = yp;
-
1883 qreal b = yp;
executed (the execution status of this line is deduced): qreal b = yp;
-
1884 if (h < 0)
evaluated: h < 0
TRUEFALSE
yes
Evaluation Count:12
yes
Evaluation Count:2654
12-2654
1885 t += h;
executed: t += h;
Execution Count:12
12
1886 else -
1887 b += h;
executed: b += h;
Execution Count:2654
2654
1888 if (t == b) // null rect
evaluated: t == b
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:2665
1-2665
1889 return false;
executed: return false;
Execution Count:1
1
1890 -
1891 if (p.y() < t || p.y() > b)
evaluated: p.y() < t
TRUEFALSE
yes
Evaluation Count:193
yes
Evaluation Count:2472
evaluated: p.y() > b
TRUEFALSE
yes
Evaluation Count:180
yes
Evaluation Count:2292
180-2472
1892 return false;
executed: return false;
Execution Count:373
373
1893 -
1894 return true;
executed: return true;
Execution Count:2292
2292
1895} -
1896 -
1897 -
1898/*! -
1899 \fn bool QRectF::contains(qreal x, qreal y) const -
1900 \overload -
1901 -
1902 Returns true if the point (\a x, \a y) is inside or on the edge of -
1903 the rectangle; otherwise returns false. -
1904*/ -
1905 -
1906/*! -
1907 \fn bool QRectF::contains(const QRectF &rectangle) const -
1908 \overload -
1909 -
1910 Returns true if the given \a rectangle is inside this rectangle; -
1911 otherwise returns false. -
1912*/ -
1913 -
1914bool QRectF::contains(const QRectF &r) const -
1915{ -
1916 qreal l1 = xp;
executed (the execution status of this line is deduced): qreal l1 = xp;
-
1917 qreal r1 = xp;
executed (the execution status of this line is deduced): qreal r1 = xp;
-
1918 if (w < 0)
evaluated: w < 0
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:4430
4-4430
1919 l1 += w;
executed: l1 += w;
Execution Count:4
4
1920 else -
1921 r1 += w;
executed: r1 += w;
Execution Count:4430
4430
1922 if (l1 == r1) // null rect
evaluated: l1 == r1
TRUEFALSE
yes
Evaluation Count:10
yes
Evaluation Count:4424
10-4424
1923 return false;
executed: return false;
Execution Count:10
10
1924 -
1925 qreal l2 = r.xp;
executed (the execution status of this line is deduced): qreal l2 = r.xp;
-
1926 qreal r2 = r.xp;
executed (the execution status of this line is deduced): qreal r2 = r.xp;
-
1927 if (r.w < 0)
evaluated: r.w < 0
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:4420
4-4420
1928 l2 += r.w;
executed: l2 += r.w;
Execution Count:4
4
1929 else -
1930 r2 += r.w;
executed: r2 += r.w;
Execution Count:4420
4420
1931 if (l2 == r2) // null rect
evaluated: l2 == r2
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:4423
1-4423
1932 return false;
executed: return false;
Execution Count:1
1
1933 -
1934 if (l2 < l1 || r2 > r1)
evaluated: l2 < l1
TRUEFALSE
yes
Evaluation Count:134
yes
Evaluation Count:4289
evaluated: r2 > r1
TRUEFALSE
yes
Evaluation Count:138
yes
Evaluation Count:4151
134-4289
1935 return false;
executed: return false;
Execution Count:272
272
1936 -
1937 qreal t1 = yp;
executed (the execution status of this line is deduced): qreal t1 = yp;
-
1938 qreal b1 = yp;
executed (the execution status of this line is deduced): qreal b1 = yp;
-
1939 if (h < 0)
evaluated: h < 0
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:4148
3-4148
1940 t1 += h;
executed: t1 += h;
Execution Count:3
3
1941 else -
1942 b1 += h;
executed: b1 += h;
Execution Count:4148
4148
1943 if (t1 == b1) // null rect
partially evaluated: t1 == b1
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4151
0-4151
1944 return false;
never executed: return false;
0
1945 -
1946 qreal t2 = r.yp;
executed (the execution status of this line is deduced): qreal t2 = r.yp;
-
1947 qreal b2 = r.yp;
executed (the execution status of this line is deduced): qreal b2 = r.yp;
-
1948 if (r.h < 0)
evaluated: r.h < 0
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:4149
2-4149
1949 t2 += r.h;
executed: t2 += r.h;
Execution Count:2
2
1950 else -
1951 b2 += r.h;
executed: b2 += r.h;
Execution Count:4149
4149
1952 if (t2 == b2) // null rect
partially evaluated: t2 == b2
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4151
0-4151
1953 return false;
never executed: return false;
0
1954 -
1955 if (t2 < t1 || b2 > b1)
evaluated: t2 < t1
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:4146
evaluated: b2 > b1
TRUEFALSE
yes
Evaluation Count:42
yes
Evaluation Count:4104
5-4146
1956 return false;
executed: return false;
Execution Count:47
47
1957 -
1958 return true;
executed: return true;
Execution Count:4104
4104
1959} -
1960 -
1961/*! -
1962 \fn qreal QRectF::left() const -
1963 -
1964 Returns the x-coordinate of the rectangle's left edge. Equivalent -
1965 to x(). -
1966 -
1967 \sa setLeft(), topLeft(), bottomLeft() -
1968*/ -
1969 -
1970/*! -
1971 \fn qreal QRectF::top() const -
1972 -
1973 Returns the y-coordinate of the rectangle's top edge. Equivalent -
1974 to y(). -
1975 -
1976 \sa setTop(), topLeft(), topRight() -
1977*/ -
1978 -
1979/*! -
1980 \fn qreal QRectF::right() const -
1981 -
1982 Returns the x-coordinate of the rectangle's right edge. -
1983 -
1984 \sa setRight(), topRight(), bottomRight() -
1985*/ -
1986 -
1987/*! -
1988 \fn qreal QRectF::bottom() const -
1989 -
1990 Returns the y-coordinate of the rectangle's bottom edge. -
1991 -
1992 \sa setBottom(), bottomLeft(), bottomRight() -
1993*/ -
1994 -
1995/*! -
1996 \fn QPointF QRectF::topLeft() const -
1997 -
1998 Returns the position of the rectangle's top-left corner. -
1999 -
2000 \sa setTopLeft(), top(), left() -
2001*/ -
2002 -
2003/*! -
2004 \fn QPointF QRectF::bottomRight() const -
2005 -
2006 Returns the position of the rectangle's bottom-right corner. -
2007 -
2008 \sa setBottomRight(), bottom(), right() -
2009*/ -
2010 -
2011/*! -
2012 \fn QPointF QRectF::topRight() const -
2013 -
2014 Returns the position of the rectangle's top-right corner. -
2015 -
2016 \sa setTopRight(), top(), right() -
2017*/ -
2018 -
2019/*! -
2020 \fn QPointF QRectF::bottomLeft() const -
2021 -
2022 Returns the position of the rectangle's bottom-left corner. -
2023 -
2024 \sa setBottomLeft(), bottom(), left() -
2025*/ -
2026 -
2027/*! -
2028 \fn QRectF& QRectF::operator|=(const QRectF &rectangle) -
2029 -
2030 Unites this rectangle with the given \a rectangle. -
2031 -
2032 \sa united(), operator|() -
2033*/ -
2034 -
2035/*! -
2036 \fn QRectF& QRectF::operator&=(const QRectF &rectangle) -
2037 -
2038 Intersects this rectangle with the given \a rectangle. -
2039 -
2040 \sa intersected(), operator|=() -
2041*/ -
2042 -
2043 -
2044/*! -
2045 \fn QRectF QRectF::operator|(const QRectF &rectangle) const -
2046 -
2047 Returns the bounding rectangle of this rectangle and the given \a rectangle. -
2048 -
2049 \sa united(), operator|=() -
2050*/ -
2051 -
2052QRectF QRectF::operator|(const QRectF &r) const -
2053{ -
2054 if (isNull())
evaluated: isNull()
TRUEFALSE
yes
Evaluation Count:2260
yes
Evaluation Count:2408
2260-2408
2055 return r;
executed: return r;
Execution Count:2260
2260
2056 if (r.isNull())
evaluated: r.isNull()
TRUEFALSE
yes
Evaluation Count:9
yes
Evaluation Count:2399
9-2399
2057 return *this;
executed: return *this;
Execution Count:9
9
2058 -
2059 qreal left = xp;
executed (the execution status of this line is deduced): qreal left = xp;
-
2060 qreal right = xp;
executed (the execution status of this line is deduced): qreal right = xp;
-
2061 if (w < 0)
evaluated: w < 0
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:2395
4-2395
2062 left += w;
executed: left += w;
Execution Count:4
4
2063 else -
2064 right += w;
executed: right += w;
Execution Count:2395
2395
2065 -
2066 if (r.w < 0) {
evaluated: r.w < 0
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:2395
4-2395
2067 left = qMin(left, r.xp + r.w);
executed (the execution status of this line is deduced): left = qMin(left, r.xp + r.w);
-
2068 right = qMax(right, r.xp);
executed (the execution status of this line is deduced): right = qMax(right, r.xp);
-
2069 } else {
executed: }
Execution Count:4
4
2070 left = qMin(left, r.xp);
executed (the execution status of this line is deduced): left = qMin(left, r.xp);
-
2071 right = qMax(right, r.xp + r.w);
executed (the execution status of this line is deduced): right = qMax(right, r.xp + r.w);
-
2072 }
executed: }
Execution Count:2395
2395
2073 -
2074 qreal top = yp;
executed (the execution status of this line is deduced): qreal top = yp;
-
2075 qreal bottom = yp;
executed (the execution status of this line is deduced): qreal bottom = yp;
-
2076 if (h < 0)
evaluated: h < 0
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:2395
4-2395
2077 top += h;
executed: top += h;
Execution Count:4
4
2078 else -
2079 bottom += h;
executed: bottom += h;
Execution Count:2395
2395
2080 -
2081 if (r.h < 0) {
evaluated: r.h < 0
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:2395
4-2395
2082 top = qMin(top, r.yp + r.h);
executed (the execution status of this line is deduced): top = qMin(top, r.yp + r.h);
-
2083 bottom = qMax(bottom, r.yp);
executed (the execution status of this line is deduced): bottom = qMax(bottom, r.yp);
-
2084 } else {
executed: }
Execution Count:4
4
2085 top = qMin(top, r.yp);
executed (the execution status of this line is deduced): top = qMin(top, r.yp);
-
2086 bottom = qMax(bottom, r.yp + r.h);
executed (the execution status of this line is deduced): bottom = qMax(bottom, r.yp + r.h);
-
2087 }
executed: }
Execution Count:2395
2395
2088 -
2089 return QRectF(left, top, right - left, bottom - top);
executed: return QRectF(left, top, right - left, bottom - top);
Execution Count:2399
2399
2090} -
2091 -
2092/*! -
2093 \fn QRectF QRectF::unite(const QRectF &rectangle) const -
2094 \obsolete -
2095 -
2096 Use united(\a rectangle) instead. -
2097*/ -
2098 -
2099/*! -
2100 \fn QRectF QRectF::united(const QRectF &rectangle) const -
2101 \since 4.2 -
2102 -
2103 Returns the bounding rectangle of this rectangle and the given \a -
2104 rectangle. -
2105 -
2106 \image qrect-unite.png -
2107 -
2108 \sa intersected() -
2109*/ -
2110 -
2111 -
2112/*! -
2113 \fn QRectF QRectF::operator &(const QRectF &rectangle) const -
2114 -
2115 Returns the intersection of this rectangle and the given \a -
2116 rectangle. Returns an empty rectangle if there is no intersection. -
2117 -
2118 \sa operator&=(), intersected() -
2119*/ -
2120 -
2121QRectF QRectF::operator&(const QRectF &r) const -
2122{ -
2123 qreal l1 = xp;
executed (the execution status of this line is deduced): qreal l1 = xp;
-
2124 qreal r1 = xp;
executed (the execution status of this line is deduced): qreal r1 = xp;
-
2125 if (w < 0)
evaluated: w < 0
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:3014
8-3014
2126 l1 += w;
executed: l1 += w;
Execution Count:8
8
2127 else -
2128 r1 += w;
executed: r1 += w;
Execution Count:3014
3014
2129 if (l1 == r1) // null rect
evaluated: l1 == r1
TRUEFALSE
yes
Evaluation Count:19
yes
Evaluation Count:3003
19-3003
2130 return QRectF();
executed: return QRectF();
Execution Count:19
19
2131 -
2132 qreal l2 = r.xp;
executed (the execution status of this line is deduced): qreal l2 = r.xp;
-
2133 qreal r2 = r.xp;
executed (the execution status of this line is deduced): qreal r2 = r.xp;
-
2134 if (r.w < 0)
evaluated: r.w < 0
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:2999
4-2999
2135 l2 += r.w;
executed: l2 += r.w;
Execution Count:4
4
2136 else -
2137 r2 += r.w;
executed: r2 += r.w;
Execution Count:2999
2999
2138 if (l2 == r2) // null rect
evaluated: l2 == r2
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:3000
3-3000
2139 return QRectF();
executed: return QRectF();
Execution Count:3
3
2140 -
2141 if (l1 >= r2 || l2 >= r1)
evaluated: l1 >= r2
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:2999
evaluated: l2 >= r1
TRUEFALSE
yes
Evaluation Count:18
yes
Evaluation Count:2981
1-2999
2142 return QRectF();
executed: return QRectF();
Execution Count:19
19
2143 -
2144 qreal t1 = yp;
executed (the execution status of this line is deduced): qreal t1 = yp;
-
2145 qreal b1 = yp;
executed (the execution status of this line is deduced): qreal b1 = yp;
-
2146 if (h < 0)
evaluated: h < 0
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:2978
3-2978
2147 t1 += h;
executed: t1 += h;
Execution Count:3
3
2148 else -
2149 b1 += h;
executed: b1 += h;
Execution Count:2978
2978
2150 if (t1 == b1) // null rect
partially evaluated: t1 == b1
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2981
0-2981
2151 return QRectF();
never executed: return QRectF();
0
2152 -
2153 qreal t2 = r.yp;
executed (the execution status of this line is deduced): qreal t2 = r.yp;
-
2154 qreal b2 = r.yp;
executed (the execution status of this line is deduced): qreal b2 = r.yp;
-
2155 if (r.h < 0)
evaluated: r.h < 0
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:2978
3-2978
2156 t2 += r.h;
executed: t2 += r.h;
Execution Count:3
3
2157 else -
2158 b2 += r.h;
executed: b2 += r.h;
Execution Count:2978
2978
2159 if (t2 == b2) // null rect
partially evaluated: t2 == b2
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2981
0-2981
2160 return QRectF();
never executed: return QRectF();
0
2161 -
2162 if (t1 >= b2 || t2 >= b1)
evaluated: t1 >= b2
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:2979
evaluated: t2 >= b1
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:2977
2-2979
2163 return QRectF();
executed: return QRectF();
Execution Count:4
4
2164 -
2165 QRectF tmp;
executed (the execution status of this line is deduced): QRectF tmp;
-
2166 tmp.xp = qMax(l1, l2);
executed (the execution status of this line is deduced): tmp.xp = qMax(l1, l2);
-
2167 tmp.yp = qMax(t1, t2);
executed (the execution status of this line is deduced): tmp.yp = qMax(t1, t2);
-
2168 tmp.w = qMin(r1, r2) - tmp.xp;
executed (the execution status of this line is deduced): tmp.w = qMin(r1, r2) - tmp.xp;
-
2169 tmp.h = qMin(b1, b2) - tmp.yp;
executed (the execution status of this line is deduced): tmp.h = qMin(b1, b2) - tmp.yp;
-
2170 return tmp;
executed: return tmp;
Execution Count:2977
2977
2171} -
2172 -
2173/*! -
2174 \fn QRectF QRectF::intersect(const QRectF &rectangle) const -
2175 \obsolete -
2176 -
2177 Use intersected(\a rectangle) instead. -
2178*/ -
2179 -
2180/*! -
2181 \fn QRectF QRectF::intersected(const QRectF &rectangle) const -
2182 \since 4.2 -
2183 -
2184 Returns the intersection of this rectangle and the given \a -
2185 rectangle. Note that \c {r.intersected(s)} is equivalent to \c -
2186 {r & s}. -
2187 -
2188 \image qrect-intersect.png -
2189 -
2190 \sa intersects(), united(), operator&=() -
2191*/ -
2192 -
2193/*! -
2194 \fn bool QRectF::intersects(const QRectF &rectangle) const -
2195 -
2196 Returns true if this rectangle intersects with the given \a -
2197 rectangle (i.e. there is a non-empty area of overlap between -
2198 them), otherwise returns false. -
2199 -
2200 The intersection rectangle can be retrieved using the intersected() -
2201 function. -
2202 -
2203 \sa contains() -
2204*/ -
2205 -
2206bool QRectF::intersects(const QRectF &r) const -
2207{ -
2208 qreal l1 = xp;
executed (the execution status of this line is deduced): qreal l1 = xp;
-
2209 qreal r1 = xp;
executed (the execution status of this line is deduced): qreal r1 = xp;
-
2210 if (w < 0)
evaluated: w < 0
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:1574
4-1574
2211 l1 += w;
executed: l1 += w;
Execution Count:4
4
2212 else -
2213 r1 += w;
executed: r1 += w;
Execution Count:1574
1574
2214 if (l1 == r1) // null rect
evaluated: l1 == r1
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:1576
2-1576
2215 return false;
executed: return false;
Execution Count:2
2
2216 -
2217 qreal l2 = r.xp;
executed (the execution status of this line is deduced): qreal l2 = r.xp;
-
2218 qreal r2 = r.xp;
executed (the execution status of this line is deduced): qreal r2 = r.xp;
-
2219 if (r.w < 0)
evaluated: r.w < 0
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:1572
4-1572
2220 l2 += r.w;
executed: l2 += r.w;
Execution Count:4
4
2221 else -
2222 r2 += r.w;
executed: r2 += r.w;
Execution Count:1572
1572
2223 if (l2 == r2) // null rect
evaluated: l2 == r2
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1575
1-1575
2224 return false;
executed: return false;
Execution Count:1
1
2225 -
2226 if (l1 >= r2 || l2 >= r1)
evaluated: l1 >= r2
TRUEFALSE
yes
Evaluation Count:47
yes
Evaluation Count:1528
evaluated: l2 >= r1
TRUEFALSE
yes
Evaluation Count:61
yes
Evaluation Count:1467
47-1528
2227 return false;
executed: return false;
Execution Count:108
108
2228 -
2229 qreal t1 = yp;
executed (the execution status of this line is deduced): qreal t1 = yp;
-
2230 qreal b1 = yp;
executed (the execution status of this line is deduced): qreal b1 = yp;
-
2231 if (h < 0)
evaluated: h < 0
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:1464
3-1464
2232 t1 += h;
executed: t1 += h;
Execution Count:3
3
2233 else -
2234 b1 += h;
executed: b1 += h;
Execution Count:1464
1464
2235 if (t1 == b1) // null rect
partially evaluated: t1 == b1
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1467
0-1467
2236 return false;
never executed: return false;
0
2237 -
2238 qreal t2 = r.yp;
executed (the execution status of this line is deduced): qreal t2 = r.yp;
-
2239 qreal b2 = r.yp;
executed (the execution status of this line is deduced): qreal b2 = r.yp;
-
2240 if (r.h < 0)
evaluated: r.h < 0
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:1464
3-1464
2241 t2 += r.h;
executed: t2 += r.h;
Execution Count:3
3
2242 else -
2243 b2 += r.h;
executed: b2 += r.h;
Execution Count:1464
1464
2244 if (t2 == b2) // null rect
partially evaluated: t2 == b2
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1467
0-1467
2245 return false;
never executed: return false;
0
2246 -
2247 if (t1 >= b2 || t2 >= b1)
evaluated: t1 >= b2
TRUEFALSE
yes
Evaluation Count:24
yes
Evaluation Count:1443
evaluated: t2 >= b1
TRUEFALSE
yes
Evaluation Count:78
yes
Evaluation Count:1365
24-1443
2248 return false;
executed: return false;
Execution Count:102
102
2249 -
2250 return true;
executed: return true;
Execution Count:1365
1365
2251} -
2252 -
2253/*! -
2254 \fn QRect QRectF::toRect() const -
2255 -
2256 Returns a QRect based on the values of this rectangle. Note that the -
2257 coordinates in the returned rectangle are rounded to the nearest integer. -
2258 -
2259 \sa QRectF(), toAlignedRect() -
2260*/ -
2261 -
2262/*! -
2263 \fn QRect QRectF::toAlignedRect() const -
2264 \since 4.3 -
2265 -
2266 Returns a QRect based on the values of this rectangle that is the -
2267 smallest possible integer rectangle that completely contains this -
2268 rectangle. -
2269 -
2270 \sa toRect() -
2271*/ -
2272 -
2273QRect QRectF::toAlignedRect() const -
2274{ -
2275 int xmin = int(qFloor(xp));
executed (the execution status of this line is deduced): int xmin = int(qFloor(xp));
-
2276 int xmax = int(qCeil(xp + w));
executed (the execution status of this line is deduced): int xmax = int(qCeil(xp + w));
-
2277 int ymin = int(qFloor(yp));
executed (the execution status of this line is deduced): int ymin = int(qFloor(yp));
-
2278 int ymax = int(qCeil(yp + h));
executed (the execution status of this line is deduced): int ymax = int(qCeil(yp + h));
-
2279 return QRect(xmin, ymin, xmax - xmin, ymax - ymin);
executed: return QRect(xmin, ymin, xmax - xmin, ymax - ymin);
Execution Count:43026
43026
2280} -
2281 -
2282/*! -
2283 \fn void QRectF::moveCenter(const QPointF &position) -
2284 -
2285 Moves the rectangle, leaving the center point at the given \a -
2286 position. The rectangle's size is unchanged. -
2287 -
2288 \sa center() -
2289*/ -
2290 -
2291/*! -
2292 \fn bool operator==(const QRectF &r1, const QRectF &r2) -
2293 \relates QRectF -
2294 -
2295 Returns true if the rectangles \a r1 and \a r2 are equal, -
2296 otherwise returns false. -
2297*/ -
2298 -
2299 -
2300/*! -
2301 \fn bool operator!=(const QRectF &r1, const QRectF &r2) -
2302 \relates QRectF -
2303 -
2304 Returns true if the rectangles \a r1 and \a r2 are different, otherwise -
2305 returns false. -
2306*/ -
2307 -
2308/***************************************************************************** -
2309 QRectF stream functions -
2310 *****************************************************************************/ -
2311#ifndef QT_NO_DATASTREAM -
2312/*! -
2313 \fn QDataStream &operator<<(QDataStream &stream, const QRectF &rectangle) -
2314 -
2315 \relates QRectF -
2316 -
2317 Writes the \a rectangle to the \a stream, and returns a reference to the -
2318 stream. -
2319 -
2320 \sa {Serializing Qt Data Types} -
2321*/ -
2322 -
2323QDataStream &operator<<(QDataStream &s, const QRectF &r) -
2324{ -
2325 s << double(r.x()) << double(r.y()) << double(r.width()) << double(r.height());
executed (the execution status of this line is deduced): s << double(r.x()) << double(r.y()) << double(r.width()) << double(r.height());
-
2326 return s;
executed: return s;
Execution Count:72
72
2327} -
2328 -
2329/*! -
2330 \fn QDataStream &operator>>(QDataStream &stream, QRectF &rectangle) -
2331 -
2332 \relates QRectF -
2333 -
2334 Reads a \a rectangle from the \a stream, and returns a reference to the -
2335 stream. -
2336 -
2337 \sa {Serializing Qt Data Types} -
2338*/ -
2339 -
2340QDataStream &operator>>(QDataStream &s, QRectF &r) -
2341{ -
2342 double x, y, w, h;
executed (the execution status of this line is deduced): double x, y, w, h;
-
2343 s >> x;
executed (the execution status of this line is deduced): s >> x;
-
2344 s >> y;
executed (the execution status of this line is deduced): s >> y;
-
2345 s >> w;
executed (the execution status of this line is deduced): s >> w;
-
2346 s >> h;
executed (the execution status of this line is deduced): s >> h;
-
2347 r.setRect(qreal(x), qreal(y), qreal(w), qreal(h));
executed (the execution status of this line is deduced): r.setRect(qreal(x), qreal(y), qreal(w), qreal(h));
-
2348 return s;
executed: return s;
Execution Count:75
75
2349} -
2350 -
2351#endif // QT_NO_DATASTREAM -
2352 -
2353 -
2354#ifndef QT_NO_DEBUG_STREAM -
2355QDebug operator<<(QDebug dbg, const QRectF &r) { -
2356 dbg.nospace() << "QRectF(" << r.x() << ',' << r.y() << ' '
executed (the execution status of this line is deduced): dbg.nospace() << "QRectF(" << r.x() << ',' << r.y() << ' '
-
2357 << r.width() << 'x' << r.height() << ')';
executed (the execution status of this line is deduced): << r.width() << 'x' << r.height() << ')';
-
2358 return dbg.space();
executed: return dbg.space();
Execution Count:1
1
2359} -
2360#endif -
2361 -
2362QT_END_NAMESPACE -
2363 -
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial