<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/src/kernel/qrect.cpp:42 --> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"> <title>QRect Class</title> <style type="text/css"><!-- fn { margin-left: 1cm; text-indent: -1cm; } a:link { color: #004faf; text-decoration: none } a:visited { color: #672967; text-decoration: none } body { background: #ffffff; color: black; } --></style> </head> <body> <table border="0" cellpadding="0" cellspacing="0" width="100%"> <tr bgcolor="#E5E5E5"> <td valign=center> <a href="index.html"> <font color="#004faf">Home</font></a> | <a href="classes.html"> <font color="#004faf">All Classes</font></a> | <a href="mainclasses.html"> <font color="#004faf">Main Classes</font></a> | <a href="annotated.html"> <font color="#004faf">Annotated</font></a> | <a href="groups.html"> <font color="#004faf">Grouped Classes</font></a> | <a href="functions.html"> <font color="#004faf">Functions</font></a> </td> <td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>QRect Class Reference</h1> <p>The QRect class defines a rectangle in the plane. <a href="#details">More...</a> <p><tt>#include <<a href="qrect-h.html">qrect.h</a>></tt> <p><a href="qrect-members.html">List of all member functions.</a> <h2>Public Members</h2> <ul> <li class=fn><a href="#QRect"><b>QRect</b></a> ()</li> <li class=fn><a href="#QRect-2"><b>QRect</b></a> ( const QPoint & topLeft, const QPoint & bottomRight )</li> <li class=fn><a href="#QRect-3"><b>QRect</b></a> ( const QPoint & topLeft, const QSize & size )</li> <li class=fn><a href="#QRect-4"><b>QRect</b></a> ( int left, int top, int width, int height )</li> <li class=fn>bool <a href="#isNull"><b>isNull</b></a> () const</li> <li class=fn>bool <a href="#isEmpty"><b>isEmpty</b></a> () const</li> <li class=fn>bool <a href="#isValid"><b>isValid</b></a> () const</li> <li class=fn>QRect <a href="#normalize"><b>normalize</b></a> () const</li> <li class=fn>int <a href="#left"><b>left</b></a> () const</li> <li class=fn>int <a href="#top"><b>top</b></a> () const</li> <li class=fn>int <a href="#right"><b>right</b></a> () const</li> <li class=fn>int <a href="#bottom"><b>bottom</b></a> () const</li> <li class=fn>QCOORD & <a href="#rLeft"><b>rLeft</b></a> ()</li> <li class=fn>QCOORD & <a href="#rTop"><b>rTop</b></a> ()</li> <li class=fn>QCOORD & <a href="#rRight"><b>rRight</b></a> ()</li> <li class=fn>QCOORD & <a href="#rBottom"><b>rBottom</b></a> ()</li> <li class=fn>int <a href="#x"><b>x</b></a> () const</li> <li class=fn>int <a href="#y"><b>y</b></a> () const</li> <li class=fn>void <a href="#setLeft"><b>setLeft</b></a> ( int pos )</li> <li class=fn>void <a href="#setTop"><b>setTop</b></a> ( int pos )</li> <li class=fn>void <a href="#setRight"><b>setRight</b></a> ( int pos )</li> <li class=fn>void <a href="#setBottom"><b>setBottom</b></a> ( int pos )</li> <li class=fn>void <a href="#setX"><b>setX</b></a> ( int x )</li> <li class=fn>void <a href="#setY"><b>setY</b></a> ( int y )</li> <li class=fn>void <a href="#setTopLeft"><b>setTopLeft</b></a> ( const QPoint & p )</li> <li class=fn>void <a href="#setBottomRight"><b>setBottomRight</b></a> ( const QPoint & p )</li> <li class=fn>void <a href="#setTopRight"><b>setTopRight</b></a> ( const QPoint & p )</li> <li class=fn>void <a href="#setBottomLeft"><b>setBottomLeft</b></a> ( const QPoint & p )</li> <li class=fn>QPoint <a href="#topLeft"><b>topLeft</b></a> () const</li> <li class=fn>QPoint <a href="#bottomRight"><b>bottomRight</b></a> () const</li> <li class=fn>QPoint <a href="#topRight"><b>topRight</b></a> () const</li> <li class=fn>QPoint <a href="#bottomLeft"><b>bottomLeft</b></a> () const</li> <li class=fn>QPoint <a href="#center"><b>center</b></a> () const</li> <li class=fn>void <a href="#rect"><b>rect</b></a> ( int * x, int * y, int * w, int * h ) const</li> <li class=fn>void <a href="#coords"><b>coords</b></a> ( int * xp1, int * yp1, int * xp2, int * yp2 ) const</li> <li class=fn>void <a href="#moveLeft"><b>moveLeft</b></a> ( int pos )</li> <li class=fn>void <a href="#moveTop"><b>moveTop</b></a> ( int pos )</li> <li class=fn>void <a href="#moveRight"><b>moveRight</b></a> ( int pos )</li> <li class=fn>void <a href="#moveBottom"><b>moveBottom</b></a> ( int pos )</li> <li class=fn>void <a href="#moveTopLeft"><b>moveTopLeft</b></a> ( const QPoint & p )</li> <li class=fn>void <a href="#moveBottomRight"><b>moveBottomRight</b></a> ( const QPoint & p )</li> <li class=fn>void <a href="#moveTopRight"><b>moveTopRight</b></a> ( const QPoint & p )</li> <li class=fn>void <a href="#moveBottomLeft"><b>moveBottomLeft</b></a> ( const QPoint & p )</li> <li class=fn>void <a href="#moveCenter"><b>moveCenter</b></a> ( const QPoint & p )</li> <li class=fn>void <a href="#moveBy"><b>moveBy</b></a> ( int dx, int dy )</li> <li class=fn>void <a href="#setRect"><b>setRect</b></a> ( int x, int y, int w, int h )</li> <li class=fn>void <a href="#setCoords"><b>setCoords</b></a> ( int xp1, int yp1, int xp2, int yp2 )</li> <li class=fn>void <a href="#addCoords"><b>addCoords</b></a> ( int xp1, int yp1, int xp2, int yp2 )</li> <li class=fn>QSize <a href="#size"><b>size</b></a> () const</li> <li class=fn>int <a href="#width"><b>width</b></a> () const</li> <li class=fn>int <a href="#height"><b>height</b></a> () const</li> <li class=fn>void <a href="#setWidth"><b>setWidth</b></a> ( int w )</li> <li class=fn>void <a href="#setHeight"><b>setHeight</b></a> ( int h )</li> <li class=fn>void <a href="#setSize"><b>setSize</b></a> ( const QSize & s )</li> <li class=fn>QRect <a href="#operator|"><b>operator|</b></a> ( const QRect & r ) const</li> <li class=fn>QRect <a href="#operator-and"><b>operator&</b></a> ( const QRect & r ) const</li> <li class=fn>QRect & <a href="#operator|-eq"><b>operator|=</b></a> ( const QRect & r )</li> <li class=fn>QRect & <a href="#operator-and-eq"><b>operator&=</b></a> ( const QRect & r )</li> <li class=fn>bool <a href="#contains"><b>contains</b></a> ( const QPoint & p, bool proper = FALSE ) const</li> <li class=fn>bool <a href="#contains-2"><b>contains</b></a> ( int x, int y ) const</li> <li class=fn>bool <a href="#contains-3"><b>contains</b></a> ( int x, int y, bool proper ) const</li> <li class=fn>bool <a href="#contains-4"><b>contains</b></a> ( const QRect & r, bool proper = FALSE ) const</li> <li class=fn>QRect <a href="#unite"><b>unite</b></a> ( const QRect & r ) const</li> <li class=fn>QRect <a href="#intersect"><b>intersect</b></a> ( const QRect & r ) const</li> <li class=fn>bool <a href="#intersects"><b>intersects</b></a> ( const QRect & r ) const</li> </ul> <h2>Related Functions</h2> <ul> <li class=fn>bool <a href="#operator-eq-eq"><b>operator==</b></a> ( const QRect & r1, const QRect & r2 )</li> <li class=fn>bool <a href="#operator!-eq"><b>operator!=</b></a> ( const QRect & r1, const QRect & r2 )</li> <li class=fn>QDataStream & <a href="#operator-lt-lt"><b>operator<<</b></a> ( QDataStream & s, const QRect & r )</li> <li class=fn>QDataStream & <a href="#operator-gt-gt"><b>operator>></b></a> ( QDataStream & s, QRect & r )</li> </ul> <hr><a name="details"></a><h2>Detailed Description</h2> The QRect class defines a rectangle in the plane. <p> <p> 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. <p> The coordinate type is QCOORD (defined in <a href="qwindowdefs-h.html">qwindowdefs.h</a> as <tt>int</tt>). The minimum value of QCOORD is QCOORD_MIN (-2147483648) and the maximum value is QCOORD_MAX (2147483647). <p> 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. <p> Generally, <em>width = right - left + 1</em> and <em>height = bottom - top + 1</em>. 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. <p> 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. <p> A QRect can be constructed with a set of left, top, width and height integers, from two QPoints or from a <a href="qpoint.html">QPoint</a> and a <a href="qsize.html">QSize</a>. After creation the dimensions can be changed, e.g. with <a href="#setLeft">setLeft</a>(), <a href="#setRight">setRight</a>(), <a href="#setTop">setTop</a>() and <a href="#setBottom">setBottom</a>(), or by setting sizes, e.g. <a href="#setWidth">setWidth</a>(), <a href="#setHeight">setHeight</a>() and <a href="#setSize">setSize</a>(). The dimensions can also be changed with the move functions, e.g. <a href="#moveBy">moveBy</a>(), <a href="#moveCenter">moveCenter</a>(), <a href="#moveBottomRight">moveBottomRight</a>(), etc. You can also add coordinates to a rectangle with <a href="#addCoords">addCoords</a>(). <p> You can test to see if a QRect contains a specific point with <a href="#contains">contains</a>(). You can also test to see if two QRects intersect with <a href="#intersects">intersects</a>() (see also <a href="#intersect">intersect</a>()). To get the bounding rectangle of two QRects use <a href="#unite">unite</a>(). <p> <p>See also <a href="qpoint.html">QPoint</a>, <a href="qsize.html">QSize</a>, <a href="graphics.html">Graphics Classes</a>, and <a href="images.html">Image Processing Classes</a>. <hr><h2>Member Function Documentation</h2> <h3 class=fn><a name="QRect"></a>QRect::QRect () </h3> <p> Constructs an invalid rectangle. <h3 class=fn><a name="QRect-2"></a>QRect::QRect ( const <a href="qpoint.html">QPoint</a> & topLeft, const <a href="qpoint.html">QPoint</a> & bottomRight ) </h3> Constructs a rectangle with <em>topLeft</em> as the top-left corner and <em>bottomRight</em> as the bottom-right corner. <h3 class=fn><a name="QRect-3"></a>QRect::QRect ( const <a href="qpoint.html">QPoint</a> & topLeft, const <a href="qsize.html">QSize</a> & size ) </h3> Constructs a rectangle with <em>topLeft</em> as the top-left corner and <em>size</em> as the rectangle size. <h3 class=fn><a name="QRect-4"></a>QRect::QRect ( int left, int top, int width, int height ) </h3> <p> Constructs a rectangle with the <em>top</em>, <em>left</em> corner and <em>width</em> and <em>height</em>. <p> Example (creates three identical rectangles): <pre> QRect r1( QPoint(100,200), QPoint(110,215) ); QRect r2( QPoint(100,200), QSize(11,16) ); QRect r3( 100, 200, 11, 16 ); </pre> <h3 class=fn>void <a name="addCoords"></a>QRect::addCoords ( int xp1, int yp1, int xp2, int yp2 ) </h3> Adds <em>xp1</em>, <em>yp1</em>, <em>xp2</em> and <em>yp2</em> respectively to the existing coordinates of the rectangle. <p>Examples: <a href="qaxserver-example-multiple.html#x2544">multiple/ax1.h</a> and <a href="qaxserver-example-multiple.html#x2549">multiple/ax2.h</a>. <h3 class=fn>int <a name="bottom"></a>QRect::bottom () const </h3> <p> Returns the bottom coordinate of the rectangle. <p> <p>See also <a href="#setBottom">setBottom</a>(), <a href="#top">top</a>(), <a href="#bottomLeft">bottomLeft</a>(), and <a href="#bottomRight">bottomRight</a>(). <p>Examples: <a href="qaction-application-example.html#x1152">action/application.cpp</a>, <a href="simple-application-example.html#x1570">application/application.cpp</a>, <a href="desktop-example.html#x1748">desktop/desktop.cpp</a>, <a href="helpviewer-example.html#x1008">helpviewer/helpwindow.cpp</a>, <a href="qfd-example.html#x2003">qfd/fontdisplayer.cpp</a>, <a href="scribble-example.html#x925">scribble/scribble.cpp</a>, and <a href="themes-example.html#x236">themes/wood.cpp</a>. <h3 class=fn><a href="qpoint.html">QPoint</a> <a name="bottomLeft"></a>QRect::bottomLeft () const </h3> <p> Returns the bottom-left position of the rectangle. <p> <p>See also <a href="#setBottomLeft">setBottomLeft</a>(), <a href="#moveBottomLeft">moveBottomLeft</a>(), <a href="#topRight">topRight</a>(), <a href="#bottom">bottom</a>(), and <a href="#left">left</a>(). <p>Example: <a href="tictac-example.html#x32">tictac/tictac.cpp</a>. <h3 class=fn><a href="qpoint.html">QPoint</a> <a name="bottomRight"></a>QRect::bottomRight () const </h3> <p> Returns the bottom-right position of the rectangle. <p> <p>See also <a href="#setBottomRight">setBottomRight</a>(), <a href="#moveBottomRight">moveBottomRight</a>(), <a href="#topLeft">topLeft</a>(), <a href="#right">right</a>(), and <a href="#bottom">bottom</a>(). <p>Example: <a href="tictac-example.html#x33">tictac/tictac.cpp</a>. <h3 class=fn><a href="qpoint.html">QPoint</a> <a name="center"></a>QRect::center () const </h3> <p> Returns the center point of the rectangle. <p> <p>See also <a href="#moveCenter">moveCenter</a>(), <a href="#topLeft">topLeft</a>(), <a href="#bottomRight">bottomRight</a>(), <a href="#topRight">topRight</a>(), and <a href="#bottomLeft">bottomLeft</a>(). <p>Example: <a href="tooltip-example.html#x447">tooltip/tooltip.cpp</a>. <h3 class=fn>bool <a name="contains"></a>QRect::contains ( const <a href="qpoint.html">QPoint</a> & p, bool proper = FALSE ) const </h3> Returns TRUE if the point <em>p</em> is inside or on the edge of the rectangle; otherwise returns FALSE. <p> If <em>proper</em> is TRUE, this function returns TRUE only if <em>p</em> is inside (not on the edge). <p>Example: <a href="tutorial1-14.html#x2426">t14/cannon.cpp</a>. <h3 class=fn>bool <a name="contains-2"></a>QRect::contains ( int x, int y ) const </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> Returns TRUE if the point <em>x</em>, <em>y</em> is inside this rectangle; otherwise returns FALSE. <h3 class=fn>bool <a name="contains-3"></a>QRect::contains ( int x, int y, bool proper ) const </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> Returns TRUE if the point <em>x</em>, <em>y</em> is inside this rectangle; otherwise returns FALSE. <p> If <em>proper</em> is TRUE, this function returns TRUE only if the point is entirely inside (not on the edge). <h3 class=fn>bool <a name="contains-4"></a>QRect::contains ( const <a href="qrect.html">QRect</a> & r, bool proper = FALSE ) const </h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function. <p> Returns TRUE if the rectangle <em>r</em> is inside this rectangle; otherwise returns FALSE. <p> If <em>proper</em> is TRUE, this function returns TRUE only if <em>r</em> is entirely inside (not on the edge). <p> <p>See also <a href="#unite">unite</a>(), <a href="#intersect">intersect</a>(), and <a href="#intersects">intersects</a>(). <h3 class=fn>void <a name="coords"></a>QRect::coords ( int * xp1, int * yp1, int * xp2, int * yp2 ) const </h3> Extracts the rectangle parameters as the top-left point <em>*xp1</em>, <em>*yp1</em> and the bottom-right point <em>*xp2</em>, <em>*yp2</em>. <p> <p>See also <a href="#setCoords">setCoords</a>() and <a href="#rect">rect</a>(). <p>Examples: <a href="themes-example.html#x297">themes/metal.cpp</a> and <a href="themes-example.html#x237">themes/wood.cpp</a>. <h3 class=fn>int <a name="height"></a>QRect::height () const </h3> <p> Returns the height of the rectangle. The height includes both the top and bottom edges, i.e. height = bottom - top + 1. <p> <p>See also <a href="#width">width</a>(), <a href="#size">size</a>(), and <a href="#setHeight">setHeight</a>(). <p>Examples: <a href="coordsys.html#x2279">aclock/aclock.cpp</a>, <a href="desktop-example.html#x1749">desktop/desktop.cpp</a>, <a href="movies-example.html#x515">movies/main.cpp</a>, <a href="scribble-example.html#x926">scribble/scribble.cpp</a>, <a href="themes-example.html#x298">themes/metal.cpp</a>, <a href="themes-example.html#x238">themes/wood.cpp</a>, and <a href="xform-example.html#x1251">xform/xform.cpp</a>. <h3 class=fn><a href="qrect.html">QRect</a> <a name="intersect"></a>QRect::intersect ( const <a href="qrect.html">QRect</a> & r ) const </h3> Returns the intersection of this rectangle and rectangle <em>r</em>. <tt>r.intersect(s)</tt> is equivalent to <tt>r&s</tt>. <h3 class=fn>bool <a name="intersects"></a>QRect::intersects ( const <a href="qrect.html">QRect</a> & r ) const </h3> Returns TRUE if this rectangle intersects with rectangle <em>r</em> (there is at least one pixel that is within both rectangles); otherwise returns FALSE. <p> <p>See also <a href="#intersect">intersect</a>() and <a href="#contains">contains</a>(). <p>Examples: <a href="tutorial1-11.html#x2370">t11/cannon.cpp</a>, <a href="tutorial1-12.html#x2393">t12/cannon.cpp</a>, <a href="tutorial1-13.html#x2406">t13/cannon.cpp</a>, and <a href="tutorial1-14.html#x2427">t14/cannon.cpp</a>. <h3 class=fn>bool <a name="isEmpty"></a>QRect::isEmpty () const </h3> <p> Returns TRUE if the rectangle is empty; otherwise returns FALSE. <p> An empty rectangle has a <a href="#left">left</a>() > <a href="#right">right</a>() or <a href="#top">top</a>() > <a href="#bottom">bottom</a>(). <p> An empty rectangle is not valid. <tt>isEmpty() == !isValid()</tt> <p> <p>See also <a href="#isNull">isNull</a>(), <a href="#isValid">isValid</a>(), and <a href="#normalize">normalize</a>(). <h3 class=fn>bool <a name="isNull"></a>QRect::isNull () const </h3> <p> Returns TRUE if the rectangle is a null rectangle; otherwise returns FALSE. <p> A null rectangle has both the width and the height set to 0, that is <a href="#right">right</a>() == <a href="#left">left</a>() - 1 and <a href="#bottom">bottom</a>() == <a href="#top">top</a>() - 1. <p> Note that if right() == left() and bottom() == top(), then the rectangle has width 1 and height 1. <p> A null rectangle is also empty. <p> A null rectangle is not valid. <p> <p>See also <a href="#isEmpty">isEmpty</a>() and <a href="#isValid">isValid</a>(). <h3 class=fn>bool <a name="isValid"></a>QRect::isValid () const </h3> <p> Returns TRUE if the rectangle is valid; otherwise returns FALSE. <p> A valid rectangle has a <a href="#left">left</a>() <= <a href="#right">right</a>() and <a href="#top">top</a>() <= <a href="#bottom">bottom</a>(). <p> Note that non-trivial operations like intersections are not defined for invalid rectangles. <p> <tt>isValid() == !isEmpty()</tt> <p> <p>See also <a href="#isNull">isNull</a>(), <a href="#isEmpty">isEmpty</a>(), and <a href="#normalize">normalize</a>(). <p>Examples: <a href="themes-example.html#x299">themes/metal.cpp</a> and <a href="tooltip-example.html#x448">tooltip/tooltip.cpp</a>. <h3 class=fn>int <a name="left"></a>QRect::left () const </h3> <p> Returns the left coordinate of the rectangle. Identical to <a href="#x">x</a>(). <p> <p>See also <a href="#setLeft">setLeft</a>(), <a href="#right">right</a>(), <a href="#topLeft">topLeft</a>(), and <a href="#bottomLeft">bottomLeft</a>(). <p>Examples: <a href="coordsys.html#x2280">aclock/aclock.cpp</a>, <a href="desktop-example.html#x1750">desktop/desktop.cpp</a>, <a href="i18n-example.html#x1942">i18n/main.cpp</a>, <a href="scribble-example.html#x927">scribble/scribble.cpp</a>, <a href="tictac-example.html#x35">tictac/tictac.cpp</a>, and <a href="xform-example.html#x1252">xform/xform.cpp</a>. <h3 class=fn>void <a name="moveBottom"></a>QRect::moveBottom ( int pos ) </h3> Sets the bottom position of the rectangle to <em>pos</em>, leaving the size unchanged. <p> <p>See also <a href="#bottom">bottom</a>(), <a href="#setBottom">setBottom</a>(), <a href="#moveLeft">moveLeft</a>(), <a href="#moveTop">moveTop</a>(), and <a href="#moveRight">moveRight</a>(). <h3 class=fn>void <a name="moveBottomLeft"></a>QRect::moveBottomLeft ( const <a href="qpoint.html">QPoint</a> & p ) </h3> Sets the bottom-left position of the rectangle to <em>p</em>, leaving the size unchanged. <p> <p>See also <a href="#bottomLeft">bottomLeft</a>(), <a href="#setBottomLeft">setBottomLeft</a>(), <a href="#moveTopLeft">moveTopLeft</a>(), <a href="#moveBottomRight">moveBottomRight</a>(), and <a href="#moveTopRight">moveTopRight</a>(). <p>Example: <a href="tutorial1-10.html#x2360">t10/cannon.cpp</a>. <h3 class=fn>void <a name="moveBottomRight"></a>QRect::moveBottomRight ( const <a href="qpoint.html">QPoint</a> & p ) </h3> Sets the bottom-right position of the rectangle to <em>p</em>, leaving the size unchanged. <p> <p>See also <a href="#bottomRight">bottomRight</a>(), <a href="#setBottomRight">setBottomRight</a>(), <a href="#moveTopLeft">moveTopLeft</a>(), <a href="#moveTopRight">moveTopRight</a>(), and <a href="#moveBottomLeft">moveBottomLeft</a>(). <h3 class=fn>void <a name="moveBy"></a>QRect::moveBy ( int dx, int dy ) </h3> Moves the rectangle <em>dx</em> along the x axis and <em>dy</em> along the y axis, relative to the current position. Positive values move the rectangle to the right and down. <p> <p>See also <a href="#moveTopLeft">moveTopLeft</a>(). <p>Examples: <a href="qaction-application-example.html#x1154">action/application.cpp</a>, <a href="simple-application-example.html#x1572">application/application.cpp</a>, <a href="helpviewer-example.html#x1010">helpviewer/helpwindow.cpp</a>, <a href="mdi-example.html#x2057">mdi/application.cpp</a>, <a href="themes-example.html#x239">themes/wood.cpp</a>, and <a href="xform-example.html#x1253">xform/xform.cpp</a>. <h3 class=fn>void <a name="moveCenter"></a>QRect::moveCenter ( const <a href="qpoint.html">QPoint</a> & p ) </h3> Sets the center point of the rectangle to <em>p</em>, leaving the size unchanged. <p> <p>See also <a href="#center">center</a>(), <a href="#moveTopLeft">moveTopLeft</a>(), <a href="#moveBottomRight">moveBottomRight</a>(), <a href="#moveTopRight">moveTopRight</a>(), and <a href="#moveBottomLeft">moveBottomLeft</a>(). <p>Examples: <a href="tutorial1-11.html#x2371">t11/cannon.cpp</a> and <a href="tutorial1-12.html#x2394">t12/cannon.cpp</a>. <h3 class=fn>void <a name="moveLeft"></a>QRect::moveLeft ( int pos ) </h3> Sets the left position of the rectangle to <em>pos</em>, leaving the size unchanged. <p> <p>See also <a href="#left">left</a>(), <a href="#setLeft">setLeft</a>(), <a href="#moveTop">moveTop</a>(), <a href="#moveRight">moveRight</a>(), and <a href="#moveBottom">moveBottom</a>(). <h3 class=fn>void <a name="moveRight"></a>QRect::moveRight ( int pos ) </h3> Sets the right position of the rectangle to <em>pos</em>, leaving the size unchanged. <p> <p>See also <a href="#right">right</a>(), <a href="#setRight">setRight</a>(), <a href="#moveLeft">moveLeft</a>(), <a href="#moveTop">moveTop</a>(), and <a href="#moveBottom">moveBottom</a>(). <h3 class=fn>void <a name="moveTop"></a>QRect::moveTop ( int pos ) </h3> Sets the top position of the rectangle to <em>pos</em>, leaving the size unchanged. <p> <p>See also <a href="#top">top</a>(), <a href="#setTop">setTop</a>(), <a href="#moveLeft">moveLeft</a>(), <a href="#moveRight">moveRight</a>(), and <a href="#moveBottom">moveBottom</a>(). <h3 class=fn>void <a name="moveTopLeft"></a>QRect::moveTopLeft ( const <a href="qpoint.html">QPoint</a> & p ) </h3> Sets the top-left position of the rectangle to <em>p</em>, leaving the size unchanged. <p> <p>See also <a href="#topLeft">topLeft</a>(), <a href="#setTopLeft">setTopLeft</a>(), <a href="#moveBottomRight">moveBottomRight</a>(), <a href="#moveTopRight">moveTopRight</a>(), and <a href="#moveBottomLeft">moveBottomLeft</a>(). <p>Examples: <a href="helpsystem-example.html#x2681">helpsystem/tooltip.cpp</a> and <a href="xform-example.html#x1254">xform/xform.cpp</a>. <h3 class=fn>void <a name="moveTopRight"></a>QRect::moveTopRight ( const <a href="qpoint.html">QPoint</a> & p ) </h3> Sets the top-right position of the rectangle to <em>p</em>, leaving the size unchanged. <p> <p>See also <a href="#topRight">topRight</a>(), <a href="#setTopRight">setTopRight</a>(), <a href="#moveTopLeft">moveTopLeft</a>(), <a href="#moveBottomRight">moveBottomRight</a>(), and <a href="#moveBottomLeft">moveBottomLeft</a>(). <h3 class=fn><a href="qrect.html">QRect</a> <a name="normalize"></a>QRect::normalize () const </h3> Returns a normalized rectangle, i.e. a rectangle that has a non-negative width and height. <p> It swaps left and right if <a href="#left">left</a>() > <a href="#right">right</a>(), and swaps top and bottom if <a href="#top">top</a>() > <a href="#bottom">bottom</a>(). <p> <p>See also <a href="#isValid">isValid</a>(). <p>Example: <a href="scribble-example.html#x928">scribble/scribble.cpp</a>. <h3 class=fn><a href="qrect.html">QRect</a> <a name="operator-and"></a>QRect::operator& ( const <a href="qrect.html">QRect</a> & r ) const </h3> Returns the intersection of this rectangle and rectangle <em>r</em>. <p> Returns an empty rectangle if there is no intersection. <p> <p>See also <a href="#operator-and-eq">operator&=</a>(), <a href="#operator|">operator|</a>(), <a href="#isEmpty">isEmpty</a>(), <a href="#intersects">intersects</a>(), and <a href="#contains">contains</a>(). <h3 class=fn><a href="qrect.html">QRect</a> & <a name="operator-and-eq"></a>QRect::operator&= ( const <a href="qrect.html">QRect</a> & r ) </h3> Intersects this rectangle with rectangle <em>r</em>. <h3 class=fn><a href="qrect.html">QRect</a> <a name="operator|"></a>QRect::operator| ( const <a href="qrect.html">QRect</a> & r ) const </h3> Returns the bounding rectangle of this rectangle and rectangle <em>r</em>. <p> The bounding rectangle of a nonempty rectangle and an empty or invalid rectangle is defined to be the nonempty rectangle. <p> <p>See also <a href="#operator|-eq">operator|=</a>(), <a href="#operator-and">operator&</a>(), <a href="#intersects">intersects</a>(), and <a href="#contains">contains</a>(). <h3 class=fn><a href="qrect.html">QRect</a> & <a name="operator|-eq"></a>QRect::operator|= ( const <a href="qrect.html">QRect</a> & r ) </h3> Unites this rectangle with rectangle <em>r</em>. <h3 class=fn>QCOORD & <a name="rBottom"></a>QRect::rBottom () </h3> <p> Returns a reference to the bottom coordinate of the rectangle. <p> <p>See also <a href="#rLeft">rLeft</a>(), <a href="#rTop">rTop</a>(), and <a href="#rRight">rRight</a>(). <h3 class=fn>QCOORD & <a name="rLeft"></a>QRect::rLeft () </h3> <p> Returns a reference to the left coordinate of the rectangle. <p> <p>See also <a href="#rTop">rTop</a>(), <a href="#rRight">rRight</a>(), and <a href="#rBottom">rBottom</a>(). <h3 class=fn>QCOORD & <a name="rRight"></a>QRect::rRight () </h3> <p> Returns a reference to the right coordinate of the rectangle. <p> <p>See also <a href="#rLeft">rLeft</a>(), <a href="#rTop">rTop</a>(), and <a href="#rBottom">rBottom</a>(). <h3 class=fn>QCOORD & <a name="rTop"></a>QRect::rTop () </h3> <p> Returns a reference to the top coordinate of the rectangle. <p> <p>See also <a href="#rLeft">rLeft</a>(), <a href="#rRight">rRight</a>(), and <a href="#rBottom">rBottom</a>(). <h3 class=fn>void <a name="rect"></a>QRect::rect ( int * x, int * y, int * w, int * h ) const </h3> Extracts the rectangle parameters as the position <em>*x</em>, <em>*y</em> and width <em>*w</em> and height <em>*h</em>. <p> <p>See also <a href="#setRect">setRect</a>() and <a href="#coords">coords</a>(). <p>Examples: <a href="themes-example.html#x300">themes/metal.cpp</a> and <a href="themes-example.html#x240">themes/wood.cpp</a>. <h3 class=fn>int <a name="right"></a>QRect::right () const </h3> <p> Returns the right coordinate of the rectangle. <p> <p>See also <a href="#setRight">setRight</a>(), <a href="#left">left</a>(), <a href="#topRight">topRight</a>(), and <a href="#bottomRight">bottomRight</a>(). <p>Examples: <a href="qaction-application-example.html#x1155">action/application.cpp</a>, <a href="simple-application-example.html#x1573">application/application.cpp</a>, <a href="customlayout-example.html#x1482">customlayout/flow.cpp</a>, <a href="desktop-example.html#x1751">desktop/desktop.cpp</a>, <a href="scribble-example.html#x929">scribble/scribble.cpp</a>, <a href="tutorial1-11.html#x2372">t11/cannon.cpp</a>, and <a href="themes-example.html#x241">themes/wood.cpp</a>. <h3 class=fn>void <a name="setBottom"></a>QRect::setBottom ( int pos ) </h3> <p> Sets the bottom edge of the rectangle to <em>pos</em>. May change the height, but will never change the top edge of the rectangle. <p> <p>See also <a href="#bottom">bottom</a>(), <a href="#setTop">setTop</a>(), and <a href="#setHeight">setHeight</a>(). <p>Example: <a href="scribble-example.html#x930">scribble/scribble.cpp</a>. <h3 class=fn>void <a name="setBottomLeft"></a>QRect::setBottomLeft ( const <a href="qpoint.html">QPoint</a> & p ) </h3> Set the bottom-left corner of the rectangle to <em>p</em>. May change the size, but will the never change the top-right corner of the rectangle. <p> <p>See also <a href="#bottomLeft">bottomLeft</a>(), <a href="#moveBottomLeft">moveBottomLeft</a>(), <a href="#setTopLeft">setTopLeft</a>(), <a href="#setBottomRight">setBottomRight</a>(), and <a href="#setTopRight">setTopRight</a>(). <h3 class=fn>void <a name="setBottomRight"></a>QRect::setBottomRight ( const <a href="qpoint.html">QPoint</a> & p ) </h3> Set the bottom-right corner of the rectangle to <em>p</em>. May change the size, but will the never change the top-left corner of the rectangle. <p> <p>See also <a href="#bottomRight">bottomRight</a>(), <a href="#moveBottomRight">moveBottomRight</a>(), <a href="#setTopLeft">setTopLeft</a>(), <a href="#setTopRight">setTopRight</a>(), and <a href="#setBottomLeft">setBottomLeft</a>(). <h3 class=fn>void <a name="setCoords"></a>QRect::setCoords ( int xp1, int yp1, int xp2, int yp2 ) </h3> Sets the coordinates of the rectangle's top-left corner to <em>(xp1, yp1)</em>, and the coordinates of its bottom-right corner to <em>(xp2, yp2)</em>. <p> <p>See also <a href="#coords">coords</a>() and <a href="#setRect">setRect</a>(). <h3 class=fn>void <a name="setHeight"></a>QRect::setHeight ( int h ) </h3> Sets the height of the rectangle to <em>h</em>. The top edge is not moved, but the bottom edge may be moved. <p> <p>See also <a href="#height">height</a>(), <a href="#setTop">setTop</a>(), <a href="#setBottom">setBottom</a>(), and <a href="#setSize">setSize</a>(). <p>Example: <a href="desktop-example.html#x1752">desktop/desktop.cpp</a>. <h3 class=fn>void <a name="setLeft"></a>QRect::setLeft ( int pos ) </h3> <p> Sets the left edge of the rectangle to <em>pos</em>. May change the width, but will never change the right edge of the rectangle. <p> Identical to <a href="#setX">setX</a>(). <p> <p>See also <a href="#left">left</a>(), <a href="#setTop">setTop</a>(), and <a href="#setWidth">setWidth</a>(). <p>Example: <a href="scribble-example.html#x931">scribble/scribble.cpp</a>. <h3 class=fn>void <a name="setRect"></a>QRect::setRect ( int x, int y, int w, int h ) </h3> Sets the coordinates of the rectangle's top-left corner to <em>(x, y)</em>, and its size to <em>(w, h)</em>. <p> <p>See also <a href="#rect">rect</a>() and <a href="#setCoords">setCoords</a>(). <p>Example: <a href="themes-example.html#x242">themes/wood.cpp</a>. <h3 class=fn>void <a name="setRight"></a>QRect::setRight ( int pos ) </h3> <p> Sets the right edge of the rectangle to <em>pos</em>. May change the width, but will never change the left edge of the rectangle. <p> <p>See also <a href="#right">right</a>(), <a href="#setLeft">setLeft</a>(), and <a href="#setWidth">setWidth</a>(). <p>Example: <a href="scribble-example.html#x932">scribble/scribble.cpp</a>. <h3 class=fn>void <a name="setSize"></a>QRect::setSize ( const <a href="qsize.html">QSize</a> & s ) </h3> Sets the size of the rectangle to <em>s</em>. The top-left corner is not moved. <p> <p>See also <a href="#size">size</a>(), <a href="#setWidth">setWidth</a>(), and <a href="#setHeight">setHeight</a>(). <p>Example: <a href="xform-example.html#x1255">xform/xform.cpp</a>. <h3 class=fn>void <a name="setTop"></a>QRect::setTop ( int pos ) </h3> <p> Sets the top edge of the rectangle to <em>pos</em>. May change the height, but will never change the bottom edge of the rectangle. <p> Identical to <a href="#setY">setY</a>(). <p> <p>See also <a href="#top">top</a>(), <a href="#setBottom">setBottom</a>(), and <a href="#setHeight">setHeight</a>(). <p>Example: <a href="scribble-example.html#x933">scribble/scribble.cpp</a>. <h3 class=fn>void <a name="setTopLeft"></a>QRect::setTopLeft ( const <a href="qpoint.html">QPoint</a> & p ) </h3> Set the top-left corner of the rectangle to <em>p</em>. May change the size, but will the never change the bottom-right corner of the rectangle. <p> <p>See also <a href="#topLeft">topLeft</a>(), <a href="#moveTopLeft">moveTopLeft</a>(), <a href="#setBottomRight">setBottomRight</a>(), <a href="#setTopRight">setTopRight</a>(), and <a href="#setBottomLeft">setBottomLeft</a>(). <h3 class=fn>void <a name="setTopRight"></a>QRect::setTopRight ( const <a href="qpoint.html">QPoint</a> & p ) </h3> Set the top-right corner of the rectangle to <em>p</em>. May change the size, but will the never change the bottom-left corner of the rectangle. <p> <p>See also <a href="#topRight">topRight</a>(), <a href="#moveTopRight">moveTopRight</a>(), <a href="#setTopLeft">setTopLeft</a>(), <a href="#setBottomRight">setBottomRight</a>(), and <a href="#setBottomLeft">setBottomLeft</a>(). <h3 class=fn>void <a name="setWidth"></a>QRect::setWidth ( int w ) </h3> Sets the width of the rectangle to <em>w</em>. The right edge is changed, but not the left edge. <p> <p>See also <a href="#width">width</a>(), <a href="#setLeft">setLeft</a>(), <a href="#setRight">setRight</a>(), and <a href="#setSize">setSize</a>(). <p>Example: <a href="desktop-example.html#x1753">desktop/desktop.cpp</a>. <h3 class=fn>void <a name="setX"></a>QRect::setX ( int x ) </h3> <p> Sets the x position of the rectangle (its left end) to <em>x</em>. May change the width, but will never change the right edge of the rectangle. <p> Identical to <a href="#setLeft">setLeft</a>(). <p> <p>See also <a href="#x">x</a>() and <a href="#setY">setY</a>(). <h3 class=fn>void <a name="setY"></a>QRect::setY ( int y ) </h3> <p> Sets the y position of the rectangle (its top) to <em>y</em>. May change the height, but will never change the bottom edge of the rectangle. <p> Identical to <a href="#setTop">setTop</a>(). <p> <p>See also <a href="#y">y</a>() and <a href="#setX">setX</a>(). <h3 class=fn><a href="qsize.html">QSize</a> <a name="size"></a>QRect::size () const </h3> <p> Returns the size of the rectangle. <p> <p>See also <a href="#width">width</a>() and <a href="#height">height</a>(). <p>Examples: <a href="desktop-example.html#x1754">desktop/desktop.cpp</a>, <a href="movies-example.html#x516">movies/main.cpp</a>, and <a href="tutorial1-10.html#x2361">t10/cannon.cpp</a>. <h3 class=fn>int <a name="top"></a>QRect::top () const </h3> <p> Returns the top coordinate of the rectangle. Identical to <a href="#y">y</a>(). <p> <p>See also <a href="#setTop">setTop</a>(), <a href="#bottom">bottom</a>(), <a href="#topLeft">topLeft</a>(), and <a href="#topRight">topRight</a>(). <p>Examples: <a href="coordsys.html#x2281">aclock/aclock.cpp</a>, <a href="desktop-example.html#x1755">desktop/desktop.cpp</a>, <a href="scribble-example.html#x934">scribble/scribble.cpp</a>, <a href="themes-example.html#x243">themes/wood.cpp</a>, <a href="tictac-example.html#x36">tictac/tictac.cpp</a>, and <a href="xform-example.html#x1256">xform/xform.cpp</a>. <h3 class=fn><a href="qpoint.html">QPoint</a> <a name="topLeft"></a>QRect::topLeft () const </h3> <p> Returns the top-left position of the rectangle. <p> <p>See also <a href="#setTopLeft">setTopLeft</a>(), <a href="#moveTopLeft">moveTopLeft</a>(), <a href="#bottomRight">bottomRight</a>(), <a href="#left">left</a>(), and <a href="#top">top</a>(). <p>Examples: <a href="helpsystem-example.html#x2682">helpsystem/tooltip.cpp</a>, <a href="tutorial1-10.html#x2362">t10/cannon.cpp</a>, and <a href="tictac-example.html#x37">tictac/tictac.cpp</a>. <h3 class=fn><a href="qpoint.html">QPoint</a> <a name="topRight"></a>QRect::topRight () const </h3> <p> Returns the top-right position of the rectangle. <p> <p>See also <a href="#setTopRight">setTopRight</a>(), <a href="#moveTopRight">moveTopRight</a>(), <a href="#bottomLeft">bottomLeft</a>(), <a href="#top">top</a>(), and <a href="#right">right</a>(). <p>Example: <a href="tictac-example.html#x38">tictac/tictac.cpp</a>. <h3 class=fn><a href="qrect.html">QRect</a> <a name="unite"></a>QRect::unite ( const <a href="qrect.html">QRect</a> & r ) const </h3> Returns the bounding rectangle of this rectangle and rectangle <em>r</em>. <tt>r.unite(s)</tt> is equivalent to <tt>r|s</tt>. <p>Examples: <a href="tutorial1-11.html#x2373">t11/cannon.cpp</a>, <a href="tutorial1-12.html#x2395">t12/cannon.cpp</a>, and <a href="xform-example.html#x1257">xform/xform.cpp</a>. <h3 class=fn>int <a name="width"></a>QRect::width () const </h3> <p> Returns the width of the rectangle. The width includes both the left and right edges, i.e. width = right - left + 1. <p> <p>See also <a href="#height">height</a>(), <a href="#size">size</a>(), and <a href="#setHeight">setHeight</a>(). <p>Examples: <a href="coordsys.html#x2282">aclock/aclock.cpp</a>, <a href="customlayout-example.html#x1505">customlayout/border.cpp</a>, <a href="desktop-example.html#x1756">desktop/desktop.cpp</a>, <a href="movies-example.html#x517">movies/main.cpp</a>, <a href="themes-example.html#x301">themes/metal.cpp</a>, <a href="themes-example.html#x244">themes/wood.cpp</a>, and <a href="xform-example.html#x1258">xform/xform.cpp</a>. <h3 class=fn>int <a name="x"></a>QRect::x () const </h3> <p> Returns the left coordinate of the rectangle. Identical to <a href="#left">left</a>(). <p> <p>See also <a href="#left">left</a>(), <a href="#y">y</a>(), and <a href="#setX">setX</a>(). <p>Examples: <a href="customlayout-example.html#x1506">customlayout/border.cpp</a>, <a href="desktop-example.html#x1757">desktop/desktop.cpp</a>, <a href="movies-example.html#x518">movies/main.cpp</a>, <a href="scribble-example.html#x936">scribble/scribble.cpp</a>, <a href="tutorial1-12.html#x2396">t12/cannon.cpp</a>, <a href="themes-example.html#x302">themes/metal.cpp</a>, and <a href="themes-example.html#x245">themes/wood.cpp</a>. <h3 class=fn>int <a name="y"></a>QRect::y () const </h3> <p> Returns the top coordinate of the rectangle. Identical to <a href="#top">top</a>(). <p> <p>See also <a href="#top">top</a>(), <a href="#x">x</a>(), and <a href="#setY">setY</a>(). <p>Examples: <a href="desktop-example.html#x1758">desktop/desktop.cpp</a>, <a href="movies-example.html#x519">movies/main.cpp</a>, <a href="scribble-example.html#x937">scribble/scribble.cpp</a>, <a href="tutorial1-12.html#x2397">t12/cannon.cpp</a>, <a href="tutorial1-14.html#x2429">t14/cannon.cpp</a>, <a href="themes-example.html#x303">themes/metal.cpp</a>, and <a href="themes-example.html#x246">themes/wood.cpp</a>. <hr><h2>Related Functions</h2> <h3 class=fn>bool <a name="operator!-eq"></a>operator!= ( const <a href="qrect.html">QRect</a> & r1, const <a href="qrect.html">QRect</a> & r2 ) </h3> <p> Returns TRUE if <em>r1</em> and <em>r2</em> are different; otherwise returns FALSE. <h3 class=fn><a href="qdatastream.html">QDataStream</a> & <a name="operator-lt-lt"></a>operator<< ( <a href="qdatastream.html">QDataStream</a> & s, const <a href="qrect.html">QRect</a> & r ) </h3> <p> Writes the QRect, <em>r</em>, to the stream <em>s</em>, and returns a reference to the stream. <p> <p>See also <a href="datastreamformat.html">Format of the QDataStream operators</a>. <h3 class=fn>bool <a name="operator-eq-eq"></a>operator== ( const <a href="qrect.html">QRect</a> & r1, const <a href="qrect.html">QRect</a> & r2 ) </h3> <p> Returns TRUE if <em>r1</em> and <em>r2</em> are equal; otherwise returns FALSE. <h3 class=fn><a href="qdatastream.html">QDataStream</a> & <a name="operator-gt-gt"></a>operator>> ( <a href="qdatastream.html">QDataStream</a> & s, <a href="qrect.html">QRect</a> & r ) </h3> <p> Reads a QRect from the stream <em>s</em> into rect <em>r</em> and returns a reference to the stream. <p> <p>See also <a href="datastreamformat.html">Format of the QDataStream operators</a>. <!-- eof --> <hr><p> This file is part of the <a href="index.html">Qt toolkit</a>. Copyright © 1995-2007 <a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center> <table width=100% cellspacing=0 border=0><tr> <td>Copyright © 2007 <a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a> <td align=right><div align=right>Qt 3.3.8</div> </table></div></address></body> </html>