Home | All Classes | Main Classes | Annotated | Grouped Classes | Functions |
The QRect class defines a rectangle in the plane. More...
#include <qrect.h>
A rectangle is internally represented as an upper-left corner and a bottom-right corner, but it is normally expressed as an upper-left corner and a size.
The coordinate type is QCOORD (defined in qwindowdefs.h as int). The minimum value of QCOORD is QCOORD_MIN (-2147483648) and the maximum value is QCOORD_MAX (2147483647).
Note that the size (width and height) of a rectangle might be different from what you are used to. If the top-left corner and the bottom-right corner are the same, the height and the width of the rectangle will both be 1.
Generally, width = right - left + 1 and height = bottom - top + 1. We designed it this way to make it correspond to rectangular spaces used by drawing functions in which the width and height denote a number of pixels. For example, drawing a rectangle with width and height 1 draws a single pixel.
The default coordinate system has origin (0, 0) in the top-left corner. The positive direction of the y axis is down, and the positive x axis is from left to right.
A QRect can be constructed with a set of left, top, width and height integers, from two QPoints or from a QPoint and a QSize. After creation the dimensions can be changed, e.g. with setLeft(), setRight(), setTop() and setBottom(), or by setting sizes, e.g. setWidth(), setHeight() and setSize(). The dimensions can also be changed with the move functions, e.g. moveBy(), moveCenter(), moveBottomRight(), etc. You can also add coordinates to a rectangle with addCoords().
You can test to see if a QRect contains a specific point with contains(). You can also test to see if two QRects intersect with intersects() (see also intersect()). To get the bounding rectangle of two QRects use unite().
See also QPoint, QSize, Graphics Classes and Image Processing Classes.
Constructs a rectangle with the top, left corner and width and height.
Example (creates three identical rectangles):
QRect r1( QPoint(100,200), QPoint(110,215) ); QRect r2( QPoint(100,200), QSize(11,16) ); QRect r3( 100, 200, 11, 16 );
Returns the bottom coordinate of the rectangle.
See also top(), setBottom(), bottomLeft() and bottomRight().
Examples: desktop/desktop.cpp, helpviewer/helpwindow.cpp, qfd/fontdisplayer.cpp, scribble/scribble.cpp and themes/wood.cpp.
See also moveBottomLeft(), bottomRight(), topLeft(), topRight(), bottom() and left().
Example: tictac/tictac.cpp.
See also moveBottomRight(), bottomLeft(), topLeft(), topRight(), bottom() and right().
Example: tictac/tictac.cpp.
See also moveCenter(), topLeft(), topRight(), bottomLeft() and bottomRight().
Example: tooltip/tooltip.cpp.
If proper is TRUE, this function returns TRUE only if p is inside (not on the edge).
Example: t14/cannon.cpp.
Returns TRUE if the point x, y is inside this rectangle; otherwise returns FALSE.
If proper is TRUE, this function returns TRUE only if the point is entirely inside (not on the edge).
Returns TRUE if the rectangle r is inside this rectangle; otherwise returns FALSE.
If proper is TRUE, this function returns TRUE only if r is entirely inside (not on the edge).
See also unite(), intersect() and intersects().
See also setCoords() and rect().
Examples: themes/metal.cpp and themes/wood.cpp.
See also width(), size() and setHeight().
Examples: aclock/aclock.cpp, desktop/desktop.cpp, movies/main.cpp, scribble/scribble.cpp, themes/metal.cpp, themes/wood.cpp and xform/xform.cpp.
See also intersect() and contains().
Examples: t11/cannon.cpp, t12/cannon.cpp, t13/cannon.cpp and t14/cannon.cpp.
Returns TRUE if the rectangle is empty; otherwise returns FALSE.
An empty rectangle has a left() > right() or top() > bottom().
An empty rectangle is not valid. isEmpty() == !isValid()
See also isNull() and isValid().
Returns TRUE if the rectangle is a null rectangle; otherwise returns FALSE.
A null rectangle has both the width and the height set to 0, that is right() == left() - 1 and bottom() == top() - 1.
Remember that if right() == left() and bottom() == top(), then the rectangle has width 1 and height 1.
A null rectangle is also empty.
A null rectangle is not valid.
See also isEmpty() and isValid().
Returns TRUE if the rectangle is valid or FALSE if it is invalid (empty).
A valid rectangle has a left() <= right() and top() <= bottom().
isValid() == !isEmpty()
See also isNull(), isEmpty() and normalize().
Examples: themes/metal.cpp and tooltip/tooltip.cpp.
Returns the left coordinate of the rectangle. Identical to x().
See also x(), top(), right(), setLeft(), topLeft() and bottomLeft().
Examples: aclock/aclock.cpp, desktop/desktop.cpp, qfd/fontdisplayer.cpp, scribble/scribble.cpp, tictac/tictac.cpp and xform/xform.cpp.
See also bottomLeft(), moveBottomRight(), moveTopLeft(), moveTopRight(), setBottom() and setLeft().
Example: t10/cannon.cpp.
See also bottomRight(), moveBottomLeft(), moveTopLeft(), moveTopRight(), setBottom() and setRight().
Examples: helpviewer/helpwindow.cpp, themes/wood.cpp and xform/xform.cpp.
See also center(), moveTopLeft(), moveTopRight(), moveBottomLeft() and moveBottomRight().
Examples: t11/cannon.cpp and t12/cannon.cpp.
See also topLeft(), moveTopRight(), moveBottomLeft(), moveBottomRight(), setTop() and setLeft().
Example: xform/xform.cpp.
See also topRight(), moveTopLeft(), moveBottomLeft(), moveBottomRight(), setTop() and setRight().
It swaps left and right if left() > right(), and swaps top and bottom if top() > bottom().
See also isValid().
Example: scribble/scribble.cpp.
Returns an empty rectangle if there is no intersection.
See also operator&=(), operator|(), isEmpty(), intersects() and contains().
The bounding rectangle of a nonempty rectangle and an empty or invalid rectangle is defined to be the nonempty rectangle.
See also operator|=(), operator&(), intersects() and contains().
Returns a reference to the bottom coordinate of the rectangle.
See also rLeft(), rTop() and rRight().
Returns a reference to the left coordinate of the rectangle.
See also rTop(), rRight() and rBottom().
Returns a reference to the right coordinate of the rectangle.
See also rLeft(), rTop() and rBottom().
Returns a reference to the top coordinate of the rectangle.
See also rLeft(), rRight() and rBottom().
See also setRect() and coords().
Examples: themes/metal.cpp and themes/wood.cpp.
Returns the right coordinate of the rectangle.
See also left(), setRight(), topRight() and bottomRight().
Examples: customlayout/flow.cpp, desktop/desktop.cpp, helpviewer/helpwindow.cpp, qfd/fontdisplayer.cpp, scribble/scribble.cpp, t11/cannon.cpp and themes/wood.cpp.
Sets the bottom edge of the rectangle to pos. May change the height, but will never change the top edge of the rectangle.
See also bottom(), setTop() and setHeight().
Example: scribble/scribble.cpp.
See also coords() and setRect().
See also height(), setTop(), setBottom() and setSize().
Example: desktop/desktop.cpp.
Sets the left edge of the rectangle to pos. May change the width, but will never change the right edge of the rectangle.
Identical to setX().
See also left(), setTop() and setWidth().
Example: scribble/scribble.cpp.
See also rect() and setCoords().
Example: themes/wood.cpp.
Sets the right edge of the rectangle to pos. May change the width, but will never change the left edge of the rectangle.
See also right(), setLeft() and setWidth().
Example: scribble/scribble.cpp.
See also size(), setWidth() and setHeight().
Example: xform/xform.cpp.
Sets the top edge of the rectangle to pos. May change the height, but will never change the bottom edge of the rectangle.
Identical to setY().
See also top(), setBottom() and setHeight().
Example: scribble/scribble.cpp.
See also width(), setLeft(), setRight() and setSize().
Example: desktop/desktop.cpp.
Sets the x position of the rectangle (its left end) to x. May change the width, but will never change the right edge of the rectangle.
Identical to setLeft().
Sets the y position of the rectangle (its top) to y. May change the height, but will never change the bottom edge of the rectangle.
Identical to setTop().
See also width() and height().
Examples: desktop/desktop.cpp, movies/main.cpp and t10/cannon.cpp.
Returns the top coordinate of the rectangle. Identical to y().
See also y(), left(), bottom(), setTop(), topLeft() and topRight().
Examples: aclock/aclock.cpp, desktop/desktop.cpp, helpviewer/helpwindow.cpp, scribble/scribble.cpp, themes/wood.cpp and tictac/tictac.cpp.
See also moveTopLeft(), topRight(), bottomLeft(), bottomRight(), left() and top().
Examples: t10/cannon.cpp and tictac/tictac.cpp.
See also moveTopRight(), topLeft(), bottomLeft(), bottomRight(), top() and right().
Example: tictac/tictac.cpp.
Examples: t11/cannon.cpp, t12/cannon.cpp and xform/xform.cpp.
See also height(), size() and setHeight().
Examples: aclock/aclock.cpp, customlayout/border.cpp, desktop/desktop.cpp, movies/main.cpp, themes/metal.cpp, themes/wood.cpp and xform/xform.cpp.
Returns the left coordinate of the rectangle. Identical to left().
See also left(), y() and setX().
Examples: customlayout/border.cpp, desktop/desktop.cpp, movies/main.cpp, scribble/scribble.cpp, t12/cannon.cpp, themes/metal.cpp and themes/wood.cpp.
Returns the top coordinate of the rectangle. Identical to top().
See also top(), x() and setY().
Examples: desktop/desktop.cpp, movies/main.cpp, scribble/scribble.cpp, t12/cannon.cpp, t14/cannon.cpp, themes/metal.cpp and themes/wood.cpp.
Writes the QRect, r, to the stream s, and returns a reference to the stream.
See also Format of the QDataStream operators.
Reads a QRect from the stream s into rect r and returns a reference to the stream.
See also Format of the QDataStream operators.
This file is part of the Qt toolkit. Copyright © 1995-2002 Trolltech. All Rights Reserved.
Copyright © 2002 Trolltech | Trademarks | Qt version 3.0.4
|