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 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356
|
<?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>QPainterPath 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">QPainterPath Class Reference<br /><sup><sup>[<a href="qtgui.html">QtGui</a> module]</sup></sup></h1><p>The QPainterPath class provides a container for painting operations, enabling graphical shapes to be constructed and reused. <a href="#details">More...</a></p>
<h3>Types</h3><ul><li><div class="fn" />class <b><a href="qpainterpath-element.html">Element</a></b></li><li><div class="fn" />enum <b><a href="qpainterpath.html#ElementType-enum">ElementType</a></b> { MoveToElement, LineToElement, CurveToElement, CurveToDataElement }</li></ul><h3>Methods</h3><ul><li><div class="fn" /><b><a href="qpainterpath.html#QPainterPath">__init__</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qpainterpath.html#QPainterPath-2">__init__</a></b> (<i>self</i>, QPointF <i>startPoint</i>)</li><li><div class="fn" /><b><a href="qpainterpath.html#QPainterPath-3">__init__</a></b> (<i>self</i>, QPainterPath <i>other</i>)</li><li><div class="fn" /><b><a href="qpainterpath.html#addEllipse">addEllipse</a></b> (<i>self</i>, QRectF <i>rect</i>)</li><li><div class="fn" /><b><a href="qpainterpath.html#addEllipse-2">addEllipse</a></b> (<i>self</i>, float <i>x</i>, float <i>y</i>, float <i>w</i>, float <i>h</i>)</li><li><div class="fn" /><b><a href="qpainterpath.html#addPath">addPath</a></b> (<i>self</i>, QPainterPath <i>path</i>)</li><li><div class="fn" /><b><a href="qpainterpath.html#addPolygon">addPolygon</a></b> (<i>self</i>, QPolygonF <i>polygon</i>)</li><li><div class="fn" /><b><a href="qpainterpath.html#addRect">addRect</a></b> (<i>self</i>, QRectF <i>rect</i>)</li><li><div class="fn" /><b><a href="qpainterpath.html#addRect-2">addRect</a></b> (<i>self</i>, float <i>x</i>, float <i>y</i>, float <i>w</i>, float <i>h</i>)</li><li><div class="fn" /><b><a href="qpainterpath.html#addRegion">addRegion</a></b> (<i>self</i>, QRegion <i>region</i>)</li><li><div class="fn" /><b><a href="qpainterpath.html#addText">addText</a></b> (<i>self</i>, QPointF <i>point</i>, QFont <i>f</i>, QString <i>text</i>)</li><li><div class="fn" /><b><a href="qpainterpath.html#addText-2">addText</a></b> (<i>self</i>, float <i>x</i>, float <i>y</i>, QFont <i>f</i>, QString <i>text</i>)</li><li><div class="fn" /><b><a href="qpainterpath.html#arcTo">arcTo</a></b> (<i>self</i>, QRectF <i>rect</i>, float <i>startAngle</i>, float <i>arcLength</i>)</li><li><div class="fn" /><b><a href="qpainterpath.html#arcTo-2">arcTo</a></b> (<i>self</i>, float <i>x</i>, float <i>y</i>, float <i>w</i>, float <i>h</i>, float <i>startAngle</i>, float <i>arcLenght</i>)</li><li><div class="fn" />QRectF <b><a href="qpainterpath.html#boundingRect">boundingRect</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qpainterpath.html#closeSubpath">closeSubpath</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qpainterpath.html#connectPath">connectPath</a></b> (<i>self</i>, QPainterPath <i>path</i>)</li><li><div class="fn" />bool <b><a href="qpainterpath.html#contains">contains</a></b> (<i>self</i>, QPointF <i>pt</i>)</li><li><div class="fn" />bool <b><a href="qpainterpath.html#contains-2">contains</a></b> (<i>self</i>, QRectF <i>rect</i>)</li><li><div class="fn" />QRectF <b><a href="qpainterpath.html#controlPointRect">controlPointRect</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qpainterpath.html#cubicTo">cubicTo</a></b> (<i>self</i>, QPointF <i>ctrlPt1</i>, QPointF <i>ctrlPt2</i>, QPointF <i>endPt</i>)</li><li><div class="fn" /><b><a href="qpainterpath.html#cubicTo-2">cubicTo</a></b> (<i>self</i>, float <i>ctrlPt1x</i>, float <i>ctrlPt1y</i>, float <i>ctrlPt2x</i>, float <i>ctrlPt2y</i>, float <i>endPtx</i>, float <i>endPty</i>)</li><li><div class="fn" />QPointF <b><a href="qpainterpath.html#currentPosition">currentPosition</a></b> (<i>self</i>)</li><li><div class="fn" />Element <b><a href="qpainterpath.html#elementAt">elementAt</a></b> (<i>self</i>, int <i>i</i>)</li><li><div class="fn" />int <b><a href="qpainterpath.html#elementCount">elementCount</a></b> (<i>self</i>)</li><li><div class="fn" />Qt.FillRule <b><a href="qpainterpath.html#fillRule">fillRule</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qpainterpath.html#intersects">intersects</a></b> (<i>self</i>, QRectF <i>rect</i>)</li><li><div class="fn" />bool <b><a href="qpainterpath.html#isEmpty">isEmpty</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qpainterpath.html#lineTo">lineTo</a></b> (<i>self</i>, QPointF <i>p</i>)</li><li><div class="fn" /><b><a href="qpainterpath.html#lineTo-2">lineTo</a></b> (<i>self</i>, float <i>x</i>, float <i>y</i>)</li><li><div class="fn" /><b><a href="qpainterpath.html#moveTo">moveTo</a></b> (<i>self</i>, QPointF <i>p</i>)</li><li><div class="fn" /><b><a href="qpainterpath.html#moveTo-2">moveTo</a></b> (<i>self</i>, float <i>x</i>, float <i>y</i>)</li><li><div class="fn" /><b><a href="qpainterpath.html#quadTo">quadTo</a></b> (<i>self</i>, QPointF <i>ctrlPt</i>, QPointF <i>endPt</i>)</li><li><div class="fn" /><b><a href="qpainterpath.html#quadTo-2">quadTo</a></b> (<i>self</i>, float <i>ctrlPtx</i>, float <i>ctrlPty</i>, float <i>endPtx</i>, float <i>endPty</i>)</li><li><div class="fn" /><b><a href="qpainterpath.html#setFillRule">setFillRule</a></b> (<i>self</i>, Qt.FillRule <i>fillRule</i>)</li><li><div class="fn" />QPolygonF <b><a href="qpainterpath.html#toFillPolygon">toFillPolygon</a></b> (<i>self</i>, QMatrix <i>matrix</i> = QMatrix())</li><li><div class="fn" />QPolygonF-list <b><a href="qpainterpath.html#toFillPolygons">toFillPolygons</a></b> (<i>self</i>, QMatrix <i>matrix</i> = QMatrix())</li><li><div class="fn" />QPainterPath <b><a href="qpainterpath.html#toReversed">toReversed</a></b> (<i>self</i>)</li><li><div class="fn" />QPolygonF-list <b><a href="qpainterpath.html#toSubpathPolygons">toSubpathPolygons</a></b> (<i>self</i>, QMatrix <i>matrix</i> = QMatrix())</li></ul><h3>Special Methods</h3><ul><li><div class="fn" />bool <b><a href="qpainterpath.html#__eq__">__eq__</a></b> (<i>self</i>, QPainterPath <i>other</i>)</li><li><div class="fn" />QPainterPath <b><a href="qpainterpath.html#__mul__">__mul__</a></b> (<i>self</i>, QMatrix <i>m</i>)</li><li><div class="fn" />bool <b><a href="qpainterpath.html#__ne__">__ne__</a></b> (<i>self</i>, QPainterPath <i>other</i>)</li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>The QPainterPath class provides a container for painting operations, enabling graphical shapes to be constructed and reused.</p>
<p>A painter path is an object composed of a number of graphical building blocks, such as rectangles, ellipses, lines, and curves. Building blocks can be joined in closed subpaths, for example as a rectangle or an ellipse. A closed path has coinciding start and end points. Or they can exist independently as unclosed subpaths, such as lines and curves.</p>
<p>A QPainterPath object can be used for filling, outlining, and clipping. To generate fillable outlines for a given painter path, use the <a href="qpainterpathstroker.html">QPainterPathStroker</a> class. The main advantage of painter paths over normal drawing operations is that complex shapes only need to be created once; then they can be drawn many times using only calls to the <a href="qpainter.html#drawPath">QPainter.drawPath</a>() function.</p>
<p>QPainterPath provides a collection of functions that can be used to obtain information about the path and its elements. In addition it is possible to reverse the order of the elements using the <a href="qpainterpath.html#toReversed">toReversed</a>() function. There are also several functions to convert this painter path object into a polygon representation.</p>
<ul>
<li><a href="#composing-a-qpainterpath">Composing a QPainterPath</a></li>
<li><a href="#qpainterpath-information">QPainterPath Information</a></li>
<li><a href="#qpainterpath-conversion">QPainterPath Conversion</a></li>
<li><a href="#examples">Examples</a></li>
</ul>
<a id="composing-a-qpainterpath" name="composing-a-qpainterpath" />
<h3>Composing a QPainterPath</h3>
<p>A QPainterPath object can be constructed as an empty path, with a given start point, or as a copy of another QPainterPath object. Once created, lines and curves can be added to the path using the <a href="qpainterpath.html#lineTo">lineTo</a>(), <a href="qpainterpath.html#arcTo">arcTo</a>(), <a href="qpainterpath.html#cubicTo">cubicTo</a>() and <a href="qpainterpath.html#quadTo">quadTo</a>() functions. The lines and curves stretch from the <a href="qpainterpath.html#currentPosition">currentPosition</a>() to the position passed as argument.</p>
<p>The <a href="qpainterpath.html#currentPosition">currentPosition</a>() of the QPainterPath object is always the end position of the last subpath that was added (or the initial start point). Use the <a href="qpainterpath.html#moveTo">moveTo</a>() function to move the <a href="qpainterpath.html#currentPosition">currentPosition</a>() without adding a component. The <a href="qpainterpath.html#moveTo">moveTo</a>() function implicitly starts a new subpath, and closes the previous one. Another way of starting a new subpath is to call the <a href="qpainterpath.html#closeSubpath">closeSubpath</a>() function which closes the current path by adding a line from the <a href="qpainterpath.html#currentPosition">currentPosition</a>() back to the path's start position. Note that the new path will have (0, 0) as its initial <a href="qpainterpath.html#currentPosition">currentPosition</a>().</p>
<p>QPainterPath class also provides several convenience functions to add closed subpaths to a painter path: <a href="qpainterpath.html#addEllipse">addEllipse</a>(), <a href="qpainterpath.html#addPath">addPath</a>(), <a href="qpainterpath.html#addRect">addRect</a>(), <a href="qpainterpath.html#addRegion">addRegion</a>() and <a href="qpainterpath.html#addText">addText</a>(). The <a href="qpainterpath.html#addPolygon">addPolygon</a>() function adds an <i>unclosed</i> subpath. In fact, these functions are all collections of <a href="qpainterpath.html#moveTo">moveTo</a>(), <a href="qpainterpath.html#lineTo">lineTo</a>() and <a href="qpainterpath.html#cubicTo">cubicTo</a>() operations.</p>
<p>In addition, a path can be added to the current path using the <a href="qpainterpath.html#connectPath">connectPath</a>() function. But note that this function will connect the last element of the current path to the first element of given one by adding a line.</p>
<p>Below is a code snippet that shows how a QPainterPath object can be used:</p>
<table align="center" border="0" cellpadding="2" cellspacing="1" width="100%">
<tr bgcolor="#F0F0F0" valign="top">
<td><img src="images/qpainterpath-construction.png" /></td>
<td>
<pre>
QPainterPath path;
path.addRect(20, 20, 60, 60);
path.moveTo(0, 0);
path.cubicTo(99, 0, 50, 50, 99, 99);
path.cubicTo(0, 99, 50, 50, 0, 0);
QPainter painter(this);
painter.fillRect(0, 0, 100, 100, Qt.white);
painter.setPen(QPen(QColor(79, 106, 25), 1, Qt.SolidLine,
Qt.FlatCap, Qt.MiterJoin));
painter.setBrush(QColor(122, 163, 39));
painter.drawPath(path);
</pre></td>
</tr>
</table>
<br />
<br />
<p>The painter path is initially empty when constructed. We first add a rectangle, which is a closed subpath. Then we add two bezier curves which together form a closed subpath even though they are not closed individually. Finally we draw the entire path. The path is filled using the default fill rule, <a href="qt.html#FillRule-enum">Qt.OddEvenFill</a>. Qt provides two methods for filling paths:</p>
<table align="center" border="0" cellpadding="2" cellspacing="1">
<tr bgcolor="#F0F0F0" valign="top">
<td><img src="images/qt-fillrule-oddeven.png" /></td>
<td><img src="images/qt-fillrule-winding.png" /></td>
</tr>
<tr bgcolor="#A2C511" valign="top">
<th><a href="qt.html#FillRule-enum">Qt.OddEvenFill</a></th>
<th><a href="qt.html#FillRule-enum">Qt.WindingFill</a></th>
</tr>
</table>
<br />
<br />
<p>See the Qt.Fillrule documentation for the definition of the rules. A painter path's currently set fill rule can be retrieved using the <a href="qpainterpath.html#fillRule">fillRule</a>() function, and altered using the <a href="qpainterpath.html#setFillRule">setFillRule</a>() function.</p>
<a id="qpainterpath-information" name="qpainterpath-information" />
<h3>QPainterPath Information</h3>
<p>The QPainterPath class provides a collection of functions that returns information about the path and its elements.</p>
<p>The <a href="qpainterpath.html#currentPosition">currentPosition</a>() function returns the end point of the last subpath that was added (or the initial start point). The <a href="qpainterpath.html#elementAt">elementAt</a>() function can be used to retrieve the various subpath elements, the <i>number</i> of elements can be retrieved using the <a href="qpainterpath.html#elementCount">elementCount</a>() function, and the <a href="qpainterpath.html#isEmpty">isEmpty</a>() function tells whether this QPainterPath object contains any elements at all.</p>
<p>The <a href="qpainterpath.html#controlPointRect">controlPointRect</a>() function returns the rectangle containing all the points and control points in this path. This function is significantly faster to compute than the exact <a href="qpainterpath.html#boundingRect">boundingRect</a>() which returns the bounding rectangle of this painter path with floating point precision.</p>
<p>Finally, QPainterPath provides the <a href="qpainterpath.html#contains">contains</a>() function which can be used to determine whether a given point or rectangle is inside the path, and the <a href="qpainterpath.html#intersects">intersects</a>() function which determines if any of the points inside a given rectangle also are inside this path.</p>
<a id="qpainterpath-conversion" name="qpainterpath-conversion" />
<h3>QPainterPath Conversion</h3>
<p>For compatibilty reasons, it might be required to simplify the representation of a painter path: QPainterPath provides the <a href="qpainterpath.html#toFillPolygon">toFillPolygon</a>(), <a href="qpainterpath.html#toFillPolygons">toFillPolygons</a>() and <a href="qpainterpath.html#toSubpathPolygons">toSubpathPolygons</a>() functions which convert the painter path into a polygon. The <a href="qpainterpath.html#toFillPolygon">toFillPolygon</a>() returns the painter path as one single polygon, while the two latter functions return a list of polygons.</p>
<p>The <a href="qpainterpath.html#toFillPolygons">toFillPolygons</a>() and <a href="qpainterpath.html#toSubpathPolygons">toSubpathPolygons</a>() functions are provided because it is usually faster to draw several small polygons than to draw one large polygon, even though the total number of points drawn is the same. The difference between the two is the <i>number</i> of polygons they return: The <a href="qpainterpath.html#toSubpathPolygons">toSubpathPolygons</a>() creates one polygon for each subpath regardless of intersecting subpaths (i.e. overlapping bounding rectangles), while the <a href="qpainterpath.html#toFillPolygons">toFillPolygons</a>() functions creates only one polygon for overlapping subpaths.</p>
<p>The <a href="qpainterpath.html#toFillPolygon">toFillPolygon</a>() and <a href="qpainterpath.html#toFillPolygons">toFillPolygons</a>() functions first convert all the subpaths to polygons, then uses a rewinding technique to make sure that overlapping subpaths can be filled using the correct fill rule. Note that rewinding inserts additional lines in the polygon so the outline of the fill polygon does not match the outline of the path.</p>
<a id="examples" name="examples" />
<h3>Examples</h3>
<p>Qt provides the <a href="painting-painterpaths.html">Painter Paths Example</a> and the <a href="demos-deform.html">Vector Deformation Demo</a> which are located in Qt's example and demo directories respectively.</p>
<p>The <a href="painting-painterpaths.html">Painter Paths Example</a> shows how painter paths can be used to build complex shapes for rendering and lets the user experiment with the filling and stroking. The <a href="demos-deform.html">Vector Deformation Demo</a> shows how to use QPainterPath to draw text.</p>
<table align="center" border="0" cellpadding="2" cellspacing="1">
<tr bgcolor="#F0F0F0" valign="top">
<td><img src="images/qpainterpath-example.png" /></td>
<td><img src="images/qpainterpath-demo.png" /></td>
</tr>
<tr bgcolor="#A2C511" valign="top">
<th><a href="painting-painterpaths.html">Painter Paths Example</a></th>
<th><a href="demos-deform.html">Vector Deformation Demo</a></th>
</tr>
</table>
<br />
<br />
<p>See also <a href="qpainterpathstroker.html">QPainterPathStroker</a>, <a href="qpainter.html">QPainter</a>, and <a href="qregion.html">QRegion</a>.</p>
<hr /><h2>Type Documentation</h2><h3 class="fn"><a name="ElementType-enum" />QPainterPath.ElementType</h3><p>This enum describes the types of elements used to connect vertices in subpaths.</p>
<p>Note that elements added as closed subpaths using the <a href="qpainterpath.html#addEllipse">addEllipse</a>(), <a href="qpainterpath.html#addPath">addPath</a>(), <a href="qpainterpath.html#addPolygon">addPolygon</a>(), <a href="qpainterpath.html#addRect">addRect</a>(), <a href="qpainterpath.html#addRegion">addRegion</a>() and <a href="qpainterpath.html#addText">addText</a>() convenience functions, is actually added to the path as a collection of separate elements using the <a href="qpainterpath.html#moveTo">moveTo</a>(), <a href="qpainterpath.html#lineTo">lineTo</a>() and <a href="qpainterpath.html#cubicTo">cubicTo</a>() functions.</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>QPainterPath.MoveToElement</tt></td>
<td align="center" valign="top"><tt>0</tt></td>
<td valign="top">A new subpath. See also <a href="qpainterpath.html#moveTo">moveTo</a>().</td>
</tr>
<tr>
<td valign="top"><tt>QPainterPath.LineToElement</tt></td>
<td align="center" valign="top"><tt>1</tt></td>
<td valign="top">A line. See also <a href="qpainterpath.html#lineTo">lineTo</a>().</td>
</tr>
<tr>
<td valign="top"><tt>QPainterPath.CurveToElement</tt></td>
<td align="center" valign="top"><tt>2</tt></td>
<td valign="top">A curve. See also <a href="qpainterpath.html#cubicTo">cubicTo</a>() and <a href="qpainterpath.html#quadTo">quadTo</a>().</td>
</tr>
<tr>
<td valign="top"><tt>QPainterPath.CurveToDataElement</tt></td>
<td align="center" valign="top"><tt>3</tt></td>
<td valign="top">The extra data required to describe a curve in a CurveToElement element.</td>
</tr>
</table>
<br />
<br />
<p>See also <a href="qpainterpath.html#elementAt">elementAt</a>() and <a href="qpainterpath.html#elementCount">elementCount</a>().</p>
<hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QPainterPath" />QPainterPath.__init__ (<i>self</i>)</h3><p>Constructs an empty <a href="qpainterpath.html">QPainterPath</a> object.</p>
<h3 class="fn"><a name="QPainterPath-2" />QPainterPath.__init__ (<i>self</i>, <a href="qpointf.html">QPointF</a> <i>startPoint</i>)</h3><p>Creates a <a href="qpainterpath.html">QPainterPath</a> object with the given <i>startPoint</i> as its current position.</p>
<h3 class="fn"><a name="QPainterPath-3" />QPainterPath.__init__ (<i>self</i>, <a href="qpainterpath.html">QPainterPath</a> <i>other</i>)</h3><p>Creates a <a href="qpainterpath.html">QPainterPath</a> object that is a copy of the given <i>path</i>.</p>
<p>See also <a href="qpainterpath.html#operator-eq">operator=</a>().</p>
<h3 class="fn"><a name="addEllipse" />QPainterPath.addEllipse (<i>self</i>, <a href="qrectf.html">QRectF</a> <i>rect</i>)</h3><p>Creates an ellipse within the the specified <i>boundingRectangle</i> and adds it to the painter path as a closed subpath.</p>
<p>The ellipse is composed of a clockwise curve, starting and finishing at zero degrees (the 3 o'clock position).</p>
<table align="center" border="0" cellpadding="2" cellspacing="1" width="100%">
<tr bgcolor="#F0F0F0" valign="top">
<td><img src="images/qpainterpath-addellipse.png" /></td>
<td>
<pre>
QLinearGradient myGradient;
QPen myPen;
QRectF boundingRectangle;
QPainterPath myPath;
myPath.addEllipse(boundingRectangle);
QPainter painter(this);
painter.setBrush(myGradient);
painter.setPen(myPen);
painter.drawPath(myPath);
</pre></td>
</tr>
</table>
<br />
<br />
<p>See also <a href="qpainterpath.html#arcTo">arcTo</a>(), <a href="qpainter.html#drawEllipse">QPainter.drawEllipse</a>(), and <a href="qpainterpath.html#composing-a-qpainterpath">Composing a QPainterPath</a>.</p>
<h3 class="fn"><a name="addEllipse-2" />QPainterPath.addEllipse (<i>self</i>, float <i>x</i>, float <i>y</i>, float <i>w</i>, float <i>h</i>)</h3><p>This is an overloaded member function, provided for convenience.</p>
<p>Creates an ellipse within the bounding rectangle defined by its top-left corner at (<i>x</i>, <i>y</i>), <i>width</i> and <i>height</i>, and adds it to the painter path as a closed subpath.</p>
<h3 class="fn"><a name="addPath" />QPainterPath.addPath (<i>self</i>, <a href="qpainterpath.html">QPainterPath</a> <i>path</i>)</h3><p>Adds the given <i>path</i> to <i>this</i> path as a closed subpath.</p>
<p>See also <a href="qpainterpath.html#connectPath">connectPath</a>() and <a href="qpainterpath.html#composing-a-qpainterpath">Composing a QPainterPath</a>.</p>
<h3 class="fn"><a name="addPolygon" />QPainterPath.addPolygon (<i>self</i>, <a href="qpolygonf.html">QPolygonF</a> <i>polygon</i>)</h3><p>Adds the given <i>polygon</i> to the path as an (unclosed) subpath.</p>
<p>Note that the current position after the polygon has been added, is the last point in <i>polygon</i>. To draw a line back to the first point, use the <a href="qpainterpath.html#closeSubpath">closeSubpath</a>() function.</p>
<table align="center" border="0" cellpadding="2" cellspacing="1" width="100%">
<tr bgcolor="#F0F0F0" valign="top">
<td><img src="images/qpainterpath-addpolygon.png" /></td>
<td>
<pre>
QLinearGradient myGradient;
QPen myPen;
QPolygonF myPolygon;
QPainterPath myPath;
myPath.addPolygon(myPolygon);
QPainter painter(this);
painter.setBrush(myGradient);
painter.setPen(myPen);
painter.drawPath(myPath);
</pre></td>
</tr>
</table>
<br />
<br />
<p>See also <a href="qpainterpath.html#lineTo">lineTo</a>() and <a href="qpainterpath.html#composing-a-qpainterpath">Composing a QPainterPath</a>.</p>
<h3 class="fn"><a name="addRect" />QPainterPath.addRect (<i>self</i>, <a href="qrectf.html">QRectF</a> <i>rect</i>)</h3><p>Adds the given <i>rectangle</i> to this path as a closed subpath.</p>
<p>The <i>rectangle</i> is added as a clockwise set of lines. The painter path's current position after the <i>rectangle</i> has been added is at the top-left corner of the rectangle.</p>
<table align="center" border="0" cellpadding="2" cellspacing="1" width="100%">
<tr bgcolor="#F0F0F0" valign="top">
<td><img src="images/qpainterpath-addrectangle.png" /></td>
<td>
<pre>
QLinearGradient myGradient;
QPen myPen;
QRectF myRectangle;
QPainterPath myPath;
myPath.addRect(myRectangle);
QPainter painter(this);
painter.setBrush(myGradient);
painter.setPen(myPen);
painter.drawPath(myPath);
</pre></td>
</tr>
</table>
<br />
<br />
<p>See also <a href="qpainterpath.html#addRegion">addRegion</a>(), <a href="qpainterpath.html#lineTo">lineTo</a>(), and <a href="qpainterpath.html#composing-a-qpainterpath">Composing a QPainterPath</a>.</p>
<h3 class="fn"><a name="addRect-2" />QPainterPath.addRect (<i>self</i>, float <i>x</i>, float <i>y</i>, float <i>w</i>, float <i>h</i>)</h3><p>This is an overloaded member function, provided for convenience.</p>
<p>Adds a rectangle at position (<i>x</i>, <i>y</i>), with the given <i>width</i> and <i>height</i>, as a closed subpath.</p>
<h3 class="fn"><a name="addRegion" />QPainterPath.addRegion (<i>self</i>, <a href="qregion.html">QRegion</a> <i>region</i>)</h3><p>Adds the given <i>region</i> to the path by adding each rectangle in the region as a separate closed subpath.</p>
<p>See also <a href="qpainterpath.html#addRect">addRect</a>() and <a href="qpainterpath.html#composing-a-qpainterpath">Composing a QPainterPath</a>.</p>
<h3 class="fn"><a name="addText" />QPainterPath.addText (<i>self</i>, <a href="qpointf.html">QPointF</a> <i>point</i>, <a href="qfont.html">QFont</a> <i>f</i>, <a href="qstring.html">QString</a> <i>text</i>)</h3><p>Adds the given <i>text</i> to this path as a set of closed subpaths created from the <i>font</i> supplied. The subpaths are positioned so that the left end of the text's baseline lies at the specified <i>point</i>.</p>
<table align="center" border="0" cellpadding="2" cellspacing="1" width="100%">
<tr bgcolor="#F0F0F0" valign="top">
<td><img src="images/qpainterpath-addtext.png" /></td>
<td>
<pre>
QLinearGradient myGradient;
QPen myPen;
QFont myFont;
QPointF baseline(x, y);
QPainterPath myPath;
myPath.addText(baseline, myFont, tr("Qt"));
QPainter painter(this);
painter.setBrush(myGradient);
painter.setPen(myPen);
painter.drawPath(myPath);
</pre></td>
</tr>
</table>
<br />
<br />
<p>See also <a href="qpainter.html#drawText">QPainter.drawText</a>() and <a href="qpainterpath.html#composing-a-qpainterpath">Composing a QPainterPath</a>.</p>
<h3 class="fn"><a name="addText-2" />QPainterPath.addText (<i>self</i>, float <i>x</i>, float <i>y</i>, <a href="qfont.html">QFont</a> <i>f</i>, <a href="qstring.html">QString</a> <i>text</i>)</h3><p>This is an overloaded member function, provided for convenience.</p>
<p>Adds the given <i>text</i> to this path as a set of closed subpaths created from the <i>font</i> supplied. The subpaths are positioned so that the left end of the text's baseline lies at the point specified by (<i>x</i>, <i>y</i>).</p>
<h3 class="fn"><a name="arcTo" />QPainterPath.arcTo (<i>self</i>, <a href="qrectf.html">QRectF</a> <i>rect</i>, float <i>startAngle</i>, float <i>arcLength</i>)</h3><p>Creates an arc that occupies the given <i>rectangle</i>, beginning at the specified <i>startAngle</i> and extending <i>sweepLength</i> degrees counter-clockwise.</p>
<p>Angles are specified in degrees. Clockwise arcs can be specified using negative angles.</p>
<p>Note that this function connects the starting point of the arc to the current position if they are not already connected. After the arc has been added, the current position is the last point in arc. To draw a line back to the first point, use the <a href="qpainterpath.html#closeSubpath">closeSubpath</a>() function.</p>
<table align="center" border="0" cellpadding="2" cellspacing="1" width="100%">
<tr bgcolor="#F0F0F0" valign="top">
<td><img src="images/qpainterpath-arcto.png" /></td>
<td>
<pre>
QLinearGradient myGradient;
QPen myPen;
QPointF center, startPoint;
QPainterPath myPath;
myPath.moveTo(center);
myPath.arcTo(boundingRect, startAngle,
sweepLength);
QPainter painter(this);
painter.setBrush(myGradient);
painter.setPen(myPen);
painter.drawPath(myPath);
</pre></td>
</tr>
</table>
<br />
<br />
<p>See also <a href="qpainterpath.html#addEllipse">addEllipse</a>(), <a href="qpainter.html#drawArc">QPainter.drawArc</a>(), <a href="qpainter.html#drawPie">QPainter.drawPie</a>(), and <a href="qpainterpath.html#composing-a-qpainterpath">Composing a QPainterPath</a>.</p>
<h3 class="fn"><a name="arcTo-2" />QPainterPath.arcTo (<i>self</i>, float <i>x</i>, float <i>y</i>, float <i>w</i>, float <i>h</i>, float <i>startAngle</i>, float <i>arcLenght</i>)</h3><p>This is an overloaded member function, provided for convenience.</p>
<p>Creates an arc that occupies the rectangle <a href="qrectf.html">QRectF</a>(<i>x</i>, <i>y</i>, <i>width</i>, <i>height</i>), beginning at the specified <i>startAngle</i> and extending <i>sweepLength</i> degrees counter-clockwise.</p>
<h3 class="fn"><a name="boundingRect" /><a href="qrectf.html">QRectF</a> QPainterPath.boundingRect (<i>self</i>)</h3><p>Returns the bounding rectangle of this painter path as a rectangle with floating point precision.</p>
<p>See also <a href="qpainterpath.html#controlPointRect">controlPointRect</a>().</p>
<h3 class="fn"><a name="closeSubpath" />QPainterPath.closeSubpath (<i>self</i>)</h3><p>Closes the current subpath by drawing a line to the beginning of the subpath, automatically starting a new path. The current point of the new path is (0, 0).</p>
<p>If the subpath does not contain any elements, this function does nothing.</p>
<p>See also <a href="qpainterpath.html#moveTo">moveTo</a>() and <a href="qpainterpath.html#composing-a-qpainterpath">Composing a QPainterPath</a>.</p>
<h3 class="fn"><a name="connectPath" />QPainterPath.connectPath (<i>self</i>, <a href="qpainterpath.html">QPainterPath</a> <i>path</i>)</h3><p>Connects the given <i>path</i> to <i>this</i> path by adding a line from the last element of this path to the first element of the given path.</p>
<p>See also <a href="qpainterpath.html#addPath">addPath</a>() and <a href="qpainterpath.html#composing-a-qpainterpath">Composing a QPainterPath</a>.</p>
<h3 class="fn"><a name="contains" />bool QPainterPath.contains (<i>self</i>, <a href="qpointf.html">QPointF</a> <i>pt</i>)</h3><p>Returns true if the given <i>point</i> is inside the path, otherwise returns false.</p>
<p>See also <a href="qpainterpath.html#intersects">intersects</a>().</p>
<h3 class="fn"><a name="contains-2" />bool QPainterPath.contains (<i>self</i>, <a href="qrectf.html">QRectF</a> <i>rect</i>)</h3><p>This is an overloaded member function, provided for convenience.</p>
<p>Returns true if the given <i>rectangle</i> is inside the path, otherwise returns false.</p>
<h3 class="fn"><a name="controlPointRect" /><a href="qrectf.html">QRectF</a> QPainterPath.controlPointRect (<i>self</i>)</h3><p>Returns the rectangle containing all the points and control points in this path.</p>
<p>This function is significantly faster to compute than the exact <a href="qpainterpath.html#boundingRect">boundingRect</a>(), and the returned rectangle is always a superset of the rectangle returned by <a href="qpainterpath.html#boundingRect">boundingRect</a>().</p>
<p>See also <a href="qpainterpath.html#boundingRect">boundingRect</a>().</p>
<h3 class="fn"><a name="cubicTo" />QPainterPath.cubicTo (<i>self</i>, <a href="qpointf.html">QPointF</a> <i>ctrlPt1</i>, <a href="qpointf.html">QPointF</a> <i>ctrlPt2</i>, <a href="qpointf.html">QPointF</a> <i>endPt</i>)</h3><p>Adds a cubic Bezier curve between the current position and the given <i>endPoint</i> using the control points specified by <i>c1</i>, and <i>c2</i>.</p>
<p>After the curve is added, the current position is updated to be at the end point of the curve.</p>
<table align="center" border="0" cellpadding="2" cellspacing="1" width="100%">
<tr bgcolor="#F0F0F0" valign="top">
<td><img src="images/qpainterpath-cubicto.png" /></td>
<td>
<pre>
QLinearGradient myGradient;
QPen myPen;
QPainterPath myPath;
myPath.cubicto(c1, c2, endPoint);
QPainter painter(this);
painter.setBrush(myGradient);
painter.setPen(myPen);
painter.drawPath(myPath);
</pre></td>
</tr>
</table>
<br />
<br />
<p>See also <a href="qpainterpath.html#quadTo">quadTo</a>() and <a href="qpainterpath.html#composing-a-qpainterpath">Composing a QPainterPath</a>.</p>
<h3 class="fn"><a name="cubicTo-2" />QPainterPath.cubicTo (<i>self</i>, float <i>ctrlPt1x</i>, float <i>ctrlPt1y</i>, float <i>ctrlPt2x</i>, float <i>ctrlPt2y</i>, float <i>endPtx</i>, float <i>endPty</i>)</h3><p>This is an overloaded member function, provided for convenience.</p>
<p>Adds a cubic Bezier curve between the current position and the end point (<i>endPointX</i>, <i>endPointY</i>) with control points specified by (<i>c1X</i>, <i>c1Y</i>) and (<i>c2X</i>, <i>c2Y</i>).</p>
<h3 class="fn"><a name="currentPosition" /><a href="qpointf.html">QPointF</a> QPainterPath.currentPosition (<i>self</i>)</h3><p>Returns the current position of the path.</p>
<h3 class="fn"><a name="elementAt" /><a href="qpainterpath-element.html">Element</a> QPainterPath.elementAt (<i>self</i>, int <i>i</i>)</h3><p>Returns the element at the given <i>index</i> in the painter path.</p>
<p>See also <a href="qpainterpath.html#ElementType-enum">ElementType</a>, <a href="qpainterpath.html#elementCount">elementCount</a>(), and <a href="qpainterpath.html#isEmpty">isEmpty</a>().</p>
<h3 class="fn"><a name="elementCount" />int QPainterPath.elementCount (<i>self</i>)</h3><p>Returns the number of path elements in the painter path.</p>
<p>See also <a href="qpainterpath.html#ElementType-enum">ElementType</a>, <a href="qpainterpath.html#elementAt">elementAt</a>(), and <a href="qpainterpath.html#isEmpty">isEmpty</a>().</p>
<h3 class="fn"><a name="fillRule" /><a href="qt.html#FillRule-enum">Qt.FillRule</a> QPainterPath.fillRule (<i>self</i>)</h3><p>Returns the painter path's currently set fill rule.</p>
<p>See also <a href="qpainterpath.html#setFillRule">setFillRule</a>().</p>
<h3 class="fn"><a name="intersects" />bool QPainterPath.intersects (<i>self</i>, <a href="qrectf.html">QRectF</a> <i>rect</i>)</h3><p>Returns true if any point in the given <i>rectangle</i> is inside the path; otherwise returns false.</p>
<p>See also <a href="qpainterpath.html#contains">contains</a>().</p>
<h3 class="fn"><a name="isEmpty" />bool QPainterPath.isEmpty (<i>self</i>)</h3><p>Returns true if there are no elements in this path, otherwise returns false.</p>
<p>See also <a href="qpainterpath.html#elementCount">elementCount</a>().</p>
<h3 class="fn"><a name="lineTo" />QPainterPath.lineTo (<i>self</i>, <a href="qpointf.html">QPointF</a> <i>p</i>)</h3><p>Adds a straight line from the current position to the given <i>endPoint</i>. After the line is drawn, the current position is updated to be at the end point of the line.</p>
<p>See also <a href="qpainterpath.html#addPolygon">addPolygon</a>(), <a href="qpainterpath.html#addRect">addRect</a>(), and <a href="qpainterpath.html#composing-a-qpainterpath">Composing a QPainterPath</a>.</p>
<h3 class="fn"><a name="lineTo-2" />QPainterPath.lineTo (<i>self</i>, float <i>x</i>, float <i>y</i>)</h3><p>This is an overloaded member function, provided for convenience.</p>
<p>Draws a line from the current position to the point (<i>x</i>, <i>y</i>).</p>
<h3 class="fn"><a name="moveTo" />QPainterPath.moveTo (<i>self</i>, <a href="qpointf.html">QPointF</a> <i>p</i>)</h3><p>Moves the current point to the given <i>point</i>, implicitly starting a new subpath and closing the previous one.</p>
<p>See also <a href="qpainterpath.html#closeSubpath">closeSubpath</a>() and <a href="qpainterpath.html#composing-a-qpainterpath">Composing a QPainterPath</a>.</p>
<h3 class="fn"><a name="moveTo-2" />QPainterPath.moveTo (<i>self</i>, float <i>x</i>, float <i>y</i>)</h3><p>This is an overloaded member function, provided for convenience.</p>
<p>Moves the current position to (<i>x</i>, <i>y</i>) and starts a new subpath, implicitly closing the previous path.</p>
<h3 class="fn"><a name="quadTo" />QPainterPath.quadTo (<i>self</i>, <a href="qpointf.html">QPointF</a> <i>ctrlPt</i>, <a href="qpointf.html">QPointF</a> <i>endPt</i>)</h3><p>Adds a quadratic Bezier curve between the current position and the given <i>endPoint</i> with the control point specified by <i>c</i>.</p>
<p>After the curve is added, the current point is updated to be at the end point of the curve.</p>
<p>See also <a href="qpainterpath.html#cubicTo">cubicTo</a>() and <a href="qpainterpath.html#composing-a-qpainterpath">Composing a QPainterPath</a>.</p>
<h3 class="fn"><a name="quadTo-2" />QPainterPath.quadTo (<i>self</i>, float <i>ctrlPtx</i>, float <i>ctrlPty</i>, float <i>endPtx</i>, float <i>endPty</i>)</h3><p>This is an overloaded member function, provided for convenience.</p>
<p>Adds a quadratic Bezier curve between the current point and the endpoint (<i>endPointX</i>, <i>endPointY</i>) with the control point specified by (<i>cx</i>, <i>cy</i>).</p>
<h3 class="fn"><a name="setFillRule" />QPainterPath.setFillRule (<i>self</i>, <a href="qt.html#FillRule-enum">Qt.FillRule</a> <i>fillRule</i>)</h3><p>Sets the fill rule of the painter path to the given <i>fillRule</i>. Qt provides two methods for filling paths:</p>
<table align="center" border="0" cellpadding="2" cellspacing="1">
<tr bgcolor="#F0F0F0" valign="top">
<td><img src="images/qt-fillrule-oddeven.png" /></td>
<td><img src="images/qt-fillrule-winding.png" /></td>
</tr>
<tr bgcolor="#A2C511" valign="top">
<th><a href="qt.html#FillRule-enum">Qt.OddEvenFill</a> (default)</th>
<th><a href="qt.html#FillRule-enum">Qt.WindingFill</a></th>
</tr>
</table>
<br />
<br />
<p>See also <a href="qpainterpath.html#fillRule">fillRule</a>().</p>
<h3 class="fn"><a name="toFillPolygon" /><a href="qpolygonf.html">QPolygonF</a> QPainterPath.toFillPolygon (<i>self</i>, <a href="qmatrix.html">QMatrix</a> <i>matrix</i> = QMatrix())</h3><p>Converts the path into a polygon using the given transformation <i>matrix</i>, and returns the polygon.</p>
<p>The polygon is created by first converting all subpaths to polygons, then using a rewinding technique to make sure that overlapping subpaths can be filled using the correct fill rule.</p>
<p>Note that rewinding inserts addition lines in the polygon so the outline of the fill polygon does not match the outline of the path.</p>
<p>See also <a href="qpainterpath.html#toSubpathPolygons">toSubpathPolygons</a>(), <a href="qpainterpath.html#toFillPolygons">toFillPolygons</a>(), and <a href="qpainterpath.html#qpainterpath-conversion">QPainterPath Conversion</a>.</p>
<h3 class="fn"><a name="toFillPolygons" />QPolygonF-list QPainterPath.toFillPolygons (<i>self</i>, <a href="qmatrix.html">QMatrix</a> <i>matrix</i> = QMatrix())</h3><p>Converts the path into a list of polygons using the given transformation <i>matrix</i>, and returns the list.</p>
<p>The function differs from the <a href="qpainterpath.html#toFillPolygon">toFillPolygon</a>() function in that it creates several polygons. It is provided because it is usually faster to draw several small polygons than to draw one large polygon, even though the total number of points drawn is the same.</p>
<p>The toFillPolygons() function differs from the <a href="qpainterpath.html#toSubpathPolygons">toSubpathPolygons</a>() function in that it create only polygon for subpaths that have overlapping bounding rectangles.</p>
<p>Like the <a href="qpainterpath.html#toFillPolygon">toFillPolygon</a>() function, this function uses a rewinding technique to make sure that overlapping subpaths can be filled using the correct fill rule. Note that rewinding inserts addition lines in the polygons so the outline of the fill polygon does not match the outline of the path.</p>
<p>See also <a href="qpainterpath.html#toSubpathPolygons">toSubpathPolygons</a>(), <a href="qpainterpath.html#toFillPolygon">toFillPolygon</a>(), and <a href="qpainterpath.html#qpainterpath-conversion">QPainterPath Conversion</a>.</p>
<h3 class="fn"><a name="toReversed" /><a href="qpainterpath.html">QPainterPath</a> QPainterPath.toReversed (<i>self</i>)</h3><p>Creates and returns a reversed copy of the path.</p>
<p>It is the order of the elements that is reversed: If a <a href="qpainterpath.html">QPainterPath</a> is composed by calling the <a href="qpainterpath.html#moveTo">moveTo</a>(), <a href="qpainterpath.html#lineTo">lineTo</a>() and <a href="qpainterpath.html#cubicTo">cubicTo</a>() functions in the specified order, the reversed copy is composed by calling <a href="qpainterpath.html#cubicTo">cubicTo</a>(), <a href="qpainterpath.html#lineTo">lineTo</a>() and <a href="qpainterpath.html#moveTo">moveTo</a>().</p>
<h3 class="fn"><a name="toSubpathPolygons" />QPolygonF-list QPainterPath.toSubpathPolygons (<i>self</i>, <a href="qmatrix.html">QMatrix</a> <i>matrix</i> = QMatrix())</h3><p>Converts the path into a list of polygons using the given transformation <i>matrix</i>, and returns the list.</p>
<p>This function creates one polygon for each subpath regardless of intersecting subpaths (i.e. overlapping bounding rectangles). To make sure that such overlapping subpaths are filled correctly, use the <a href="qpainterpath.html#toFillPolygons">toFillPolygons</a>() function instead.</p>
<p>See also <a href="qpainterpath.html#toFillPolygons">toFillPolygons</a>(), <a href="qpainterpath.html#toFillPolygon">toFillPolygon</a>(), and <a href="qpainterpath.html#qpainterpath-conversion">QPainterPath Conversion</a>.</p>
<h3 class="fn"><a name="__eq__" />bool QPainterPath.__eq__ (<i>self</i>, <a href="qpainterpath.html">QPainterPath</a> <i>other</i>)</h3><h3 class="fn"><a name="__mul__" /><a href="qpainterpath.html">QPainterPath</a> QPainterPath.__mul__ (<i>self</i>, <a href="qmatrix.html">QMatrix</a> <i>m</i>)</h3><h3 class="fn"><a name="__ne__" />bool QPainterPath.__ne__ (<i>self</i>, <a href="qpainterpath.html">QPainterPath</a> <i>other</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>
|