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