1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120
|
<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html><head><title>QRegion Class Reference</title><style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }
td.postheader { font-family: sans-serif }
tr.address { font-family: sans-serif }
body { background: #ffffff; color: black; }
</style></head><body><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr /><td align="left" valign="top" width="32"><img align="left" border="0" height="32" src="images/rb-logo.png" width="32" /></td><td width="1">  </td><td class="postheader" valign="center"><a href="../pyqt4ref.html"><font color="#004faf">Home</font></a> · <a href="classes.html"><font color="#004faf">All Classes</font></a> · <a href="modules.html"><font color="#004faf">Modules</font></a></td></table><h1 align="center">QRegion Class Reference<br /><sup><sup>[<a href="qtgui.html">QtGui</a> module]</sup></sup></h1><p>The QRegion class specifies a clip region for a painter. <a href="#details">More...</a></p>
<h3>Types</h3><ul><li><div class="fn" />enum <b><a href="qregion.html#RegionType-enum">RegionType</a></b> { Rectangle, Ellipse }</li></ul><h3>Methods</h3><ul><li><div class="fn" /><b><a href="qregion.html#QRegion">__init__</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qregion.html#QRegion-2">__init__</a></b> (<i>self</i>, int <i>x</i>, int <i>y</i>, int <i>w</i>, int <i>h</i>, RegionType <i>t</i> = QRegion.Rectangle)</li><li><div class="fn" /><b><a href="qregion.html#QRegion-3">__init__</a></b> (<i>self</i>, QRect <i>r</i>, RegionType <i>t</i> = QRegion.Rectangle)</li><li><div class="fn" /><b><a href="qregion.html#QRegion-4">__init__</a></b> (<i>self</i>, QPolygon <i>pa</i>, Qt.FillRule <i>fillRule</i> = Qt.OddEvenFill)</li><li><div class="fn" /><b><a href="qregion.html#QRegion-5">__init__</a></b> (<i>self</i>, QBitmap <i>bitmap</i>)</li><li><div class="fn" /><b><a href="qregion.html#QRegion-6">__init__</a></b> (<i>self</i>, QVariant)</li><li><div class="fn" /><b><a href="qregion.html#QRegion-7">__init__</a></b> (<i>self</i>, QRegion <i>region</i>)</li><li><div class="fn" />QRect <b><a href="qregion.html#boundingRect">boundingRect</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qregion.html#contains">contains</a></b> (<i>self</i>, QPoint <i>p</i>)</li><li><div class="fn" />bool <b><a href="qregion.html#contains-2">contains</a></b> (<i>self</i>, QRect <i>r</i>)</li><li><div class="fn" />QRegion <b><a href="qregion.html#eor">eor</a></b> (<i>self</i>, QRegion <i>r</i>)</li><li><div class="fn" />QRegion <b><a href="qregion.html#intersect">intersect</a></b> (<i>self</i>, QRegion <i>r</i>)</li><li><div class="fn" />bool <b><a href="qregion.html#isEmpty">isEmpty</a></b> (<i>self</i>)</li><li><div class="fn" />QRect-list <b><a href="qregion.html#rects">rects</a></b> (<i>self</i>)</li><li><div class="fn" />QRegion <b><a href="qregion.html#subtract">subtract</a></b> (<i>self</i>, QRegion <i>r</i>)</li><li><div class="fn" /><b><a href="qregion.html#translate">translate</a></b> (<i>self</i>, int <i>dx</i>, int <i>dy</i>)</li><li><div class="fn" /><b><a href="qregion.html#translate-2">translate</a></b> (<i>self</i>, QPoint <i>p</i>)</li><li><div class="fn" />QRegion <b><a href="qregion.html#translated">translated</a></b> (<i>self</i>, int <i>dx</i>, int <i>dy</i>)</li><li><div class="fn" />QRegion <b><a href="qregion.html#translated-2">translated</a></b> (<i>self</i>, QPoint <i>p</i>)</li><li><div class="fn" />QRegion <b><a href="qregion.html#unite">unite</a></b> (<i>self</i>, QRegion <i>r</i>)</li></ul><h3>Special Methods</h3><ul><li><div class="fn" />QRegion <b><a href="qregion.html#__add__">__add__</a></b> (<i>self</i>, QRegion <i>r</i>)</li><li><div class="fn" />QRegion <b><a href="qregion.html#__and__">__and__</a></b> (<i>self</i>, QRegion <i>r</i>)</li><li><div class="fn" />int <b><a href="qregion.html#__contains__">__contains__</a></b> (<i>self</i>, QPoint <i>p</i>)</li><li><div class="fn" />int <b><a href="qregion.html#__contains__-2">__contains__</a></b> (<i>self</i>, QRect <i>r</i>)</li><li><div class="fn" />bool <b><a href="qregion.html#__eq__">__eq__</a></b> (<i>self</i>, QRegion <i>r</i>)</li><li><div class="fn" />QRegion <b><a href="qregion.html#__iadd__">__iadd__</a></b> (<i>self</i>, QRegion <i>r</i>)</li><li><div class="fn" />QRegion <b><a href="qregion.html#__iand__">__iand__</a></b> (<i>self</i>, QRegion <i>r</i>)</li><li><div class="fn" />QRegion <b><a href="qregion.html#__ior__">__ior__</a></b> (<i>self</i>, QRegion <i>r</i>)</li><li><div class="fn" />QRegion <b><a href="qregion.html#__isub__">__isub__</a></b> (<i>self</i>, QRegion <i>r</i>)</li><li><div class="fn" />QRegion <b><a href="qregion.html#__ixor__">__ixor__</a></b> (<i>self</i>, QRegion <i>r</i>)</li><li><div class="fn" />QRegion <b><a href="qregion.html#__mul__">__mul__</a></b> (<i>self</i>, QMatrix <i>m</i>)</li><li><div class="fn" />bool <b><a href="qregion.html#__ne__">__ne__</a></b> (<i>self</i>, QRegion <i>r</i>)</li><li><div class="fn" />int <b><a href="qregion.html#__nonzero__">__nonzero__</a></b> (<i>self</i>)</li><li><div class="fn" />QRegion <b><a href="qregion.html#__or__">__or__</a></b> (<i>self</i>, QRegion <i>r</i>)</li><li><div class="fn" />QRegion <b><a href="qregion.html#__sub__">__sub__</a></b> (<i>self</i>, QRegion <i>r</i>)</li><li><div class="fn" />QRegion <b><a href="qregion.html#__xor__">__xor__</a></b> (<i>self</i>, QRegion <i>r</i>)</li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>The QRegion class specifies a clip region for a painter.</p>
<p>QRegion is used with <a href="qpainter.html#setClipRegion">QPainter.setClipRegion</a>() to limit the paint area to what needs to be painted. There is also a <a href="qwidget.html#repaint">QWidget.repaint</a>() function that takes a QRegion parameter. QRegion is the best tool for reducing flicker.</p>
<p>A region can be created from a rectangle, an ellipse, a polygon or a bitmap. Complex regions may be created by combining simple regions using <a href="qregion.html#unite">unite</a>(), <a href="qregion.html#intersect">intersect</a>(), <a href="qregion.html#subtract">subtract</a>(), or <a href="qregion.html#eor">eor</a>() (exclusive or). You can move a region using <a href="qregion.html#translate">translate</a>().</p>
<p>You can test whether a region <a href="qregion.html#isEmpty">isEmpty</a>() or if it <a href="qregion.html#contains">contains</a>() a <a href="qpoint.html">QPoint</a> or <a href="qrect.html">QRect</a>. The bounding rectangle can be found with <a href="qregion.html#boundingRect">boundingRect</a>().</p>
<p>The function <a href="qregion.html#rects">rects</a>() gives a decomposition of the region into rectangles.</p>
<p>Example of using complex regions:</p>
<pre>
void MyWidget.paintEvent(QPaintEvent *)
{
QPainter p; // our painter
QRegion r1(QRect(100,100,200,80), // r1 = elliptic region
QRegion.Ellipse);
QRegion r2(QRect(100,120,90,30)); // r2 = rectangular region
QRegion r3 = r1.intersect(r2); // r3 = intersection
p.begin(this); // start painting widget
p.setClipRegion(r3); // set clip region
... // paint clipped graphics
p.end(); // painting done
}
</pre>
<p>QRegion is an <a href="shclass.html">implicitly shared</a> class.</p>
<p><b>Warning:</b> Due to window system limitations, the whole coordinate space for a region is limited to the points between -32767 and 32767 on Windows 95/98/ME. You can circumvent this limitation by using a <a href="qpainterpath.html">QPainterPath</a>.</p>
<a id="additional-license-information" name="additional-license-information" />
<h3>Additional License Information</h3>
<p>On Qt/X11 and Qtopia Core, parts of this class rely on code obtained under the following license:</p>
<p>Copyright (c) 1987 X Consortium</p>
<p>Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:</p>
<p>The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.</p>
<p>THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.</p>
<p>Except as contained in this notice, the name of the X Consortium shall not be used in advertising or otherwise to promote the sale, use or other dealings in this Software without prior written authorization from the X Consortium.</p>
<hr /><h2>Type Documentation</h2><h3 class="fn"><a name="RegionType-enum" />QRegion.RegionType</h3><p>Specifies the shape of the region to be created.</p>
<table border="1" cellpadding="2" cellspacing="1" width="100%">
<tr>
<th width="25%">Constant</th>
<th width="15%">Value</th>
<th width="60%">Description</th>
</tr>
<tr>
<td valign="top"><tt>QRegion.Rectangle</tt></td>
<td align="center" valign="top"><tt>0</tt></td>
<td valign="top">the region covers the entire rectangle.</td>
</tr>
<tr>
<td valign="top"><tt>QRegion.Ellipse</tt></td>
<td align="center" valign="top"><tt>1</tt></td>
<td valign="top">the region is an ellipse inside the rectangle.</td>
</tr>
</table>
<br />
<br />
<hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QRegion" />QRegion.__init__ (<i>self</i>)</h3><p>Constructs an empty region.</p>
<p>See also <a href="qregion.html#isEmpty">isEmpty</a>().</p>
<h3 class="fn"><a name="QRegion-2" />QRegion.__init__ (<i>self</i>, int <i>x</i>, int <i>y</i>, int <i>w</i>, int <i>h</i>, <a href="qregion.html#RegionType-enum">RegionType</a> <i>t</i> = QRegion.Rectangle)</h3><p>Constructs a rectangular or elliptic region.</p>
<p>If <i>t</i> is <tt>Rectangle</tt>, the region is the filled rectangle (<i>x</i>, <i>y</i>, <i>w</i>, <i>h</i>). If <i>t</i> is <tt>Ellipse</tt>, the region is the filled ellipse with center at (<i>x</i> + <i>w</i> / 2, <i>y</i> + <i>h</i> / 2) and size (<i>w</i> ,<i>h</i>).</p>
<h3 class="fn"><a name="QRegion-3" />QRegion.__init__ (<i>self</i>, <a href="qrect.html">QRect</a> <i>r</i>, <a href="qregion.html#RegionType-enum">RegionType</a> <i>t</i> = QRegion.Rectangle)</h3><p>Constructs a polygon region from the point array <i>a</i> with the fill rule specified by <i>fillRule</i>.</p>
<p>If <i>fillRule</i> is <a href="qt.html#FillRule-enum">Qt.WindingFill</a>, the polygon region is defined using the winding algorithm; if it is <a href="qt.html#FillRule-enum">Qt.OddEvenFill</a>, the odd-even fill algorithm is used.</p>
<p><b>Warning:</b> This constructor can be used to create complex regions that will slow down painting when used.</p>
<h3 class="fn"><a name="QRegion-4" />QRegion.__init__ (<i>self</i>, <a href="qpolygon.html">QPolygon</a> <i>pa</i>, <a href="qt.html#FillRule-enum">Qt.FillRule</a> <i>fillRule</i> = Qt.OddEvenFill)</h3><h3 class="fn"><a name="QRegion-5" />QRegion.__init__ (<i>self</i>, <a href="qbitmap.html">QBitmap</a> <i>bitmap</i>)</h3><p>Constructs a new region which is equal to region <i>r</i>.</p>
<h3 class="fn"><a name="QRegion-6" />QRegion.__init__ (<i>self</i>, <a href="qvariant.html">QVariant</a>)</h3><p>Constructs a region from the bitmap <i>bm</i>.</p>
<p>The resulting region consists of the pixels in bitmap <i>bm</i> that are <a href="qt.html#GlobalColor-enum">Qt.color1</a>, as if each pixel was a 1 by 1 rectangle.</p>
<p>This constructor may create complex regions that will slow down painting when used. Note that drawing masked pixmaps can be done much faster using <a href="qpixmap.html#setMask">QPixmap.setMask</a>().</p>
<h3 class="fn"><a name="QRegion-7" />QRegion.__init__ (<i>self</i>, <a href="qregion.html">QRegion</a> <i>region</i>)</h3><p>Create a region based on the rectange <i>r</i> with region type <i>t</i>.</p>
<p>If the rectangle is invalid a null region will be created.</p>
<p>See also <a href="qregion.html#RegionType-enum">QRegion.RegionType</a>.</p>
<h3 class="fn"><a name="boundingRect" /><a href="qrect.html">QRect</a> QRegion.boundingRect (<i>self</i>)</h3><p>Returns the bounding rectangle of this region. An empty region gives a rectangle that is <a href="qrect.html#isNull">QRect.isNull</a>().</p>
<h3 class="fn"><a name="contains" />bool QRegion.contains (<i>self</i>, <a href="qpoint.html">QPoint</a> <i>p</i>)</h3><p>Returns true if the region contains the point <i>p</i>; otherwise returns false.</p>
<h3 class="fn"><a name="contains-2" />bool QRegion.contains (<i>self</i>, <a href="qrect.html">QRect</a> <i>r</i>)</h3><p>This is an overloaded member function, provided for convenience.</p>
<p>Returns true if the region overlaps the rectangle <i>r</i>; otherwise returns false.</p>
<h3 class="fn"><a name="eor" /><a href="qregion.html">QRegion</a> QRegion.eor (<i>self</i>, <a href="qregion.html">QRegion</a> <i>r</i>)</h3><p>Returns a region which is the exclusive or (XOR) of this region and <i>r</i>.</p>
<p align="center"><img alt="Region XORed" src="images/rxor.png" /></p>
<p>The figure shows the exclusive or of two elliptical regions.</p>
<h3 class="fn"><a name="intersect" /><a href="qregion.html">QRegion</a> QRegion.intersect (<i>self</i>, <a href="qregion.html">QRegion</a> <i>r</i>)</h3><p>Returns a region which is the intersection of this region and <i>r</i>.</p>
<p align="center"><img alt="Region Intersection" src="images/rintersect.png" /></p>
<p>The figure shows the intersection of two elliptical regions.</p>
<h3 class="fn"><a name="isEmpty" />bool QRegion.isEmpty (<i>self</i>)</h3><p>Returns true if the region is empty; otherwise returns false. An empty region is a region that contains no points.</p>
<p>Example:</p>
<pre>
QRegion r1(10, 10, 20, 20);
QRegion r2(40, 40, 20, 20);
QRegion r3;
r1.isNull(); // false
r1.isEmpty(); // false
r3.isNull(); // true
r3.isEmpty(); // true
r3 = r1.intersect(r2); // r3 = intersection of r1 and r2
r3.isNull(); // false
r3.isEmpty(); // true
r3 = r1.unite(r2); // r3 = union of r1 and r2
r3.isNull(); // false
r3.isEmpty(); // false
</pre>
<h3 class="fn"><a name="rects" />QRect-list QRegion.rects (<i>self</i>)</h3><p>Returns an array of non-overlapping rectangles that make up the region.</p>
<p>The union of all the rectangles is equal to the original region.</p>
<h3 class="fn"><a name="subtract" /><a href="qregion.html">QRegion</a> QRegion.subtract (<i>self</i>, <a href="qregion.html">QRegion</a> <i>r</i>)</h3><p>Returns a region which is <i>r</i> subtracted from this region.</p>
<p align="center"><img alt="Region Subtraction" src="images/rsubtract.png" /></p>
<p>The figure shows the result when the ellipse on the right is subtracted from the ellipse on the left. (<tt>left-right</tt>)</p>
<h3 class="fn"><a name="translate" />QRegion.translate (<i>self</i>, int <i>dx</i>, int <i>dy</i>)</h3><p>Translates (moves) the region <i>dx</i> along the X axis and <i>dy</i> along the Y axis.</p>
<h3 class="fn"><a name="translate-2" />QRegion.translate (<i>self</i>, <a href="qpoint.html">QPoint</a> <i>p</i>)</h3><p>This is an overloaded member function, provided for convenience.</p>
<p>Translates the region <i>point</i><i>.x()</i> along the x axis and <i>point</i><i>.y()</i> along the y axis, relative to the current position. Positive values move the region to the right and down.</p>
<p>Translates to the given <i>point</i>.</p>
<h3 class="fn"><a name="translated" /><a href="qregion.html">QRegion</a> QRegion.translated (<i>self</i>, int <i>dx</i>, int <i>dy</i>)</h3><p>Returns a copy of the region that is translated <i>dx</i> along the x axis and <i>dy</i> along the y axis, relative to the current position. Positive values move the region to the right and down.</p>
<p>This function was introduced in Qt 4.1.</p>
<p>See also <a href="qregion.html#translate">translate</a>().</p>
<h3 class="fn"><a name="translated-2" /><a href="qregion.html">QRegion</a> QRegion.translated (<i>self</i>, <a href="qpoint.html">QPoint</a> <i>p</i>)</h3><p>This is an overloaded member function, provided for convenience.</p>
<p>Returns a copy of the regtion that is translated <i>p</i><i>.x()</i> along the x axis and <i>p</i><i>.y()</i> along the y axis, relative to the current position. Positive values move the rectangle to the right and down.</p>
<p>This function was introduced in Qt 4.1.</p>
<p>See also <a href="qregion.html#translate">translate</a>().</p>
<h3 class="fn"><a name="unite" /><a href="qregion.html">QRegion</a> QRegion.unite (<i>self</i>, <a href="qregion.html">QRegion</a> <i>r</i>)</h3><p>Returns a region which is the union of this region and <i>r</i>.</p>
<p align="center"><img alt="Region Union" src="images/runion.png" /></p>
<p>The figure shows the union of two elliptical regions.</p>
<h3 class="fn"><a name="__add__" /><a href="qregion.html">QRegion</a> QRegion.__add__ (<i>self</i>, <a href="qregion.html">QRegion</a> <i>r</i>)</h3><h3 class="fn"><a name="__and__" /><a href="qregion.html">QRegion</a> QRegion.__and__ (<i>self</i>, <a href="qregion.html">QRegion</a> <i>r</i>)</h3><h3 class="fn"><a name="__contains__" />int QRegion.__contains__ (<i>self</i>, <a href="qpoint.html">QPoint</a> <i>p</i>)</h3><h3 class="fn"><a name="__contains__-2" />int QRegion.__contains__ (<i>self</i>, <a href="qrect.html">QRect</a> <i>r</i>)</h3><h3 class="fn"><a name="__eq__" />bool QRegion.__eq__ (<i>self</i>, <a href="qregion.html">QRegion</a> <i>r</i>)</h3><h3 class="fn"><a name="__iadd__" /><a href="qregion.html">QRegion</a> QRegion.__iadd__ (<i>self</i>, <a href="qregion.html">QRegion</a> <i>r</i>)</h3><h3 class="fn"><a name="__iand__" /><a href="qregion.html">QRegion</a> QRegion.__iand__ (<i>self</i>, <a href="qregion.html">QRegion</a> <i>r</i>)</h3><h3 class="fn"><a name="__ior__" /><a href="qregion.html">QRegion</a> QRegion.__ior__ (<i>self</i>, <a href="qregion.html">QRegion</a> <i>r</i>)</h3><h3 class="fn"><a name="__isub__" /><a href="qregion.html">QRegion</a> QRegion.__isub__ (<i>self</i>, <a href="qregion.html">QRegion</a> <i>r</i>)</h3><h3 class="fn"><a name="__ixor__" /><a href="qregion.html">QRegion</a> QRegion.__ixor__ (<i>self</i>, <a href="qregion.html">QRegion</a> <i>r</i>)</h3><h3 class="fn"><a name="__mul__" /><a href="qregion.html">QRegion</a> QRegion.__mul__ (<i>self</i>, <a href="qmatrix.html">QMatrix</a> <i>m</i>)</h3><h3 class="fn"><a name="__ne__" />bool QRegion.__ne__ (<i>self</i>, <a href="qregion.html">QRegion</a> <i>r</i>)</h3><h3 class="fn"><a name="__nonzero__" />int QRegion.__nonzero__ (<i>self</i>)</h3><h3 class="fn"><a name="__or__" /><a href="qregion.html">QRegion</a> QRegion.__or__ (<i>self</i>, <a href="qregion.html">QRegion</a> <i>r</i>)</h3><h3 class="fn"><a name="__sub__" /><a href="qregion.html">QRegion</a> QRegion.__sub__ (<i>self</i>, <a href="qregion.html">QRegion</a> <i>r</i>)</h3><h3 class="fn"><a name="__xor__" /><a href="qregion.html">QRegion</a> QRegion.__xor__ (<i>self</i>, <a href="qregion.html">QRegion</a> <i>r</i>)</h3><address><hr /><div align="center"><table border="0" cellspacing="0" width="100%"><tr class="address"><td width="25%">PyQt 4.0.1 for X11</td><td align="center" width="50%">Copyright © <a href="http://www.riverbankcomputing.com">Riverbank Computing Ltd</a> and <a href="http://www.trolltech.com">Trolltech AS</a> 2006</td><td align="right" width="25%">Qt 4.1.4</td></tr></table></div></address></body></html>
|