<?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="index.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#addEllipse-3">addEllipse</a></b> (<i>self</i>, QPointF <i>center</i>, float <i>rx</i>, float <i>ry</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#addRoundedRect">addRoundedRect</a></b> (<i>self</i>, QRectF <i>rect</i>, float <i>xRadius</i>, float <i>yRadius</i>, Qt.SizeMode <i>mode</i> = Qt.AbsoluteSize)</li><li><div class="fn" /><b><a href="qpainterpath.html#addRoundedRect-2">addRoundedRect</a></b> (<i>self</i>, float <i>x</i>, float <i>y</i>, float <i>w</i>, float <i>h</i>, float <i>xRadius</i>, float <i>yRadius</i>, Qt.SizeMode <i>mode</i> = Qt.AbsoluteSize)</li><li><div class="fn" /><b><a href="qpainterpath.html#addRoundRect">addRoundRect</a></b> (<i>self</i>, QRectF <i>rect</i>, int <i>xRnd</i>, int <i>yRnd</i>)</li><li><div class="fn" /><b><a href="qpainterpath.html#addRoundRect-2">addRoundRect</a></b> (<i>self</i>, float <i>x</i>, float <i>y</i>, float <i>w</i>, float <i>h</i>, int <i>xRnd</i>, int <i>yRnd</i>)</li><li><div class="fn" /><b><a href="qpainterpath.html#addRoundRect-3">addRoundRect</a></b> (<i>self</i>, QRectF <i>rect</i>, int <i>roundness</i>)</li><li><div class="fn" /><b><a href="qpainterpath.html#addRoundRect-4">addRoundRect</a></b> (<i>self</i>, float <i>x</i>, float <i>y</i>, float <i>w</i>, float <i>h</i>, int <i>roundness</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" />float <b><a href="qpainterpath.html#angleAtPercent">angleAtPercent</a></b> (<i>self</i>, float <i>t</i>)</li><li><div class="fn" /><b><a href="qpainterpath.html#arcMoveTo">arcMoveTo</a></b> (<i>self</i>, QRectF <i>rect</i>, float <i>angle</i>)</li><li><div class="fn" /><b><a href="qpainterpath.html#arcMoveTo-2">arcMoveTo</a></b> (<i>self</i>, float <i>x</i>, float <i>y</i>, float <i>w</i>, float <i>h</i>, float <i>angle</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" />bool <b><a href="qpainterpath.html#contains-3">contains</a></b> (<i>self</i>, QPainterPath <i>p</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" />QPainterPath <b><a href="qpainterpath.html#intersected">intersected</a></b> (<i>self</i>, QPainterPath <i>r</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#intersects-2">intersects</a></b> (<i>self</i>, QPainterPath <i>p</i>)</li><li><div class="fn" />bool <b><a href="qpainterpath.html#isEmpty">isEmpty</a></b> (<i>self</i>)</li><li><div class="fn" />float <b><a href="qpainterpath.html#length">length</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" />float <b><a href="qpainterpath.html#percentAtLength">percentAtLength</a></b> (<i>self</i>, float <i>t</i>)</li><li><div class="fn" />QPointF <b><a href="qpainterpath.html#pointAtPercent">pointAtPercent</a></b> (<i>self</i>, float <i>t</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#setElementPositionAt">setElementPositionAt</a></b> (<i>self</i>, int <i>i</i>, float <i>x</i>, float <i>y</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" />QPainterPath <b><a href="qpainterpath.html#simplified">simplified</a></b> (<i>self</i>)</li><li><div class="fn" />float <b><a href="qpainterpath.html#slopeAtPercent">slopeAtPercent</a></b> (<i>self</i>, float <i>t</i>)</li><li><div class="fn" />QPainterPath <b><a href="qpainterpath.html#subtracted">subtracted</a></b> (<i>self</i>, QPainterPath <i>r</i>)</li><li><div class="fn" />QPainterPath <b><a href="qpainterpath.html#subtractedInverted">subtractedInverted</a></b> (<i>self</i>, QPainterPath <i>r</i>)</li><li><div class="fn" /><b><a href="qpainterpath.html#swap">swap</a></b> (<i>self</i>, QPainterPath <i>other</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 <b><a href="qpainterpath.html#toFillPolygon-2">toFillPolygon</a></b> (<i>self</i>, QTransform <i>matrix</i>)</li><li><div class="fn" />list-of-QPolygonF <b><a href="qpainterpath.html#toFillPolygons">toFillPolygons</a></b> (<i>self</i>, QMatrix <i>matrix</i> = QMatrix())</li><li><div class="fn" />list-of-QPolygonF <b><a href="qpainterpath.html#toFillPolygons-2">toFillPolygons</a></b> (<i>self</i>, QTransform <i>matrix</i>)</li><li><div class="fn" />QPainterPath <b><a href="qpainterpath.html#toReversed">toReversed</a></b> (<i>self</i>)</li><li><div class="fn" />list-of-QPolygonF <b><a href="qpainterpath.html#toSubpathPolygons">toSubpathPolygons</a></b> (<i>self</i>, QMatrix <i>matrix</i> = QMatrix())</li><li><div class="fn" />list-of-QPolygonF <b><a href="qpainterpath.html#toSubpathPolygons-2">toSubpathPolygons</a></b> (<i>self</i>, QTransform <i>matrix</i>)</li><li><div class="fn" /><b><a href="qpainterpath.html#translate">translate</a></b> (<i>self</i>, float <i>dx</i>, float <i>dy</i>)</li><li><div class="fn" /><b><a href="qpainterpath.html#translate-2">translate</a></b> (<i>self</i>, QPointF <i>offset</i>)</li><li><div class="fn" />QPainterPath <b><a href="qpainterpath.html#translated">translated</a></b> (<i>self</i>, float <i>dx</i>, float <i>dy</i>)</li><li><div class="fn" />QPainterPath <b><a href="qpainterpath.html#translated-2">translated</a></b> (<i>self</i>, QPointF <i>offset</i>)</li><li><div class="fn" />QPainterPath <b><a href="qpainterpath.html#united">united</a></b> (<i>self</i>, QPainterPath <i>r</i>)</li></ul><h3>Special Methods</h3><ul><li><div class="fn" />QPainterPath <b><a href="qpainterpath.html#__add__">__add__</a></b> (<i>self</i>, QPainterPath <i>other</i>)</li><li><div class="fn" />QPainterPath <b><a href="qpainterpath.html#__and__">__and__</a></b> (<i>self</i>, QPainterPath <i>other</i>)</li><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#__iadd__">__iadd__</a></b> (<i>self</i>, QPainterPath <i>other</i>)</li><li><div class="fn" />QPainterPath <b><a href="qpainterpath.html#__iand__">__iand__</a></b> (<i>self</i>, QPainterPath <i>other</i>)</li><li><div class="fn" />QPainterPath <b><a href="qpainterpath.html#__ior__">__ior__</a></b> (<i>self</i>, QPainterPath <i>other</i>)</li><li><div class="fn" />QPainterPath <b><a href="qpainterpath.html#__isub__">__isub__</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" />QPainterPath <b><a href="qpainterpath.html#__mul__-2">__mul__</a></b> (<i>self</i>, QTransform <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><li><div class="fn" />QPainterPath <b><a href="qpainterpath.html#__or__">__or__</a></b> (<i>self</i>, QPainterPath <i>other</i>)</li><li><div class="fn" />QPainterPath <b><a href="qpainterpath.html#__sub__">__sub__</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> <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 class="generic" width="100%"> <tr class="odd" valign="top"> <td><img alt="" src="images/qpainterpath-construction.png" /></td> <td> <pre class="cpp"> <span class="type">QPainterPath</span> path; path<span class="operator">.</span><a href="qpainterpath.html#addRect">addRect</a>(<span class="number">20</span><span class="operator">,</span> <span class="number">20</span><span class="operator">,</span> <span class="number">60</span><span class="operator">,</span> <span class="number">60</span>); path<span class="operator">.</span><a href="qpainterpath.html#moveTo">moveTo</a>(<span class="number">0</span><span class="operator">,</span> <span class="number">0</span>); path<span class="operator">.</span><a href="qpainterpath.html#cubicTo">cubicTo</a>(<span class="number">99</span><span class="operator">,</span> <span class="number">0</span><span class="operator">,</span> <span class="number">50</span><span class="operator">,</span> <span class="number">50</span><span class="operator">,</span> <span class="number">99</span><span class="operator">,</span> <span class="number">99</span>); path<span class="operator">.</span><a href="qpainterpath.html#cubicTo">cubicTo</a>(<span class="number">0</span><span class="operator">,</span> <span class="number">99</span><span class="operator">,</span> <span class="number">50</span><span class="operator">,</span> <span class="number">50</span><span class="operator">,</span> <span class="number">0</span><span class="operator">,</span> <span class="number">0</span>); <span class="type"><a href="qpainter.html">QPainter</a></span> painter(<span class="keyword">this</span>); painter<span class="operator">.</span>fillRect(<span class="number">0</span><span class="operator">,</span> <span class="number">0</span><span class="operator">,</span> <span class="number">100</span><span class="operator">,</span> <span class="number">100</span><span class="operator">,</span> <span class="type"><a href="qt.html">Qt</a></span><span class="operator">.</span>white); painter<span class="operator">.</span>setPen(<span class="type"><a href="qpen.html">QPen</a></span>(<span class="type"><a href="qcolor.html">QColor</a></span>(<span class="number">79</span><span class="operator">,</span> <span class="number">106</span><span class="operator">,</span> <span class="number">25</span>)<span class="operator">,</span> <span class="number">1</span><span class="operator">,</span> <span class="type"><a href="qt.html">Qt</a></span><span class="operator">.</span>SolidLine<span class="operator">,</span> <span class="type"><a href="qt.html">Qt</a></span><span class="operator">.</span>FlatCap<span class="operator">,</span> <span class="type"><a href="qt.html">Qt</a></span><span class="operator">.</span>MiterJoin)); painter<span class="operator">.</span>setBrush(<span class="type"><a href="qcolor.html">QColor</a></span>(<span class="number">122</span><span class="operator">,</span> <span class="number">163</span><span class="operator">,</span> <span class="number">39</span>)); painter<span class="operator">.</span>drawPath(path); </pre></td> </tr> </table> <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 class="generic"> <thead> <tr class="qt-style"> <th><a href="qt.html#FillRule-enum">Qt.OddEvenFill</a></th> <th><a href="qt.html#FillRule-enum">Qt.WindingFill</a></th> </tr> </thead> <tr class="odd" valign="top"> <td><img alt="" src="images/qt-fillrule-oddeven.png" /></td> <td><img alt="" src="images/qt-fillrule-winding.png" /></td> </tr> </table> <p>See the <a href="qt.html#FillRule-enum">Qt.FillRule</a> 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 compatibility 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 class="generic"> <thead> <tr class="qt-style"> <th><a href="painting-painterpaths.html">Painter Paths Example</a></th> <th><a href="demos-deform.html">Vector Deformation Demo</a></th> </tr> </thead> <tr class="odd" valign="top"> <td><img alt="" src="images/qpainterpath-example.png" /></td> <td><img alt="" src="images/qpainterpath-demo.png" /></td> </tr> </table> <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 class="valuelist"> <tr class="odd" valign="top"> <th class="tblConst">Constant</th> <th class="tblval">Value</th> <th class="tbldscr">Description</th> </tr> <tr> <td class="topAlign"><tt>QPainterPath.MoveToElement</tt></td> <td class="topAlign"><tt>0</tt></td> <td class="topAlign">A new subpath. See also <a href="qpainterpath.html#moveTo">moveTo</a>().</td> </tr> <tr> <td class="topAlign"><tt>QPainterPath.LineToElement</tt></td> <td class="topAlign"><tt>1</tt></td> <td class="topAlign">A line. See also <a href="qpainterpath.html#lineTo">lineTo</a>().</td> </tr> <tr> <td class="topAlign"><tt>QPainterPath.CurveToElement</tt></td> <td class="topAlign"><tt>2</tt></td> <td class="topAlign">A curve. See also <a href="qpainterpath.html#cubicTo">cubicTo</a>() and <a href="qpainterpath.html#quadTo">quadTo</a>().</td> </tr> <tr> <td class="topAlign"><tt>QPainterPath.CurveToDataElement</tt></td> <td class="topAlign"><tt>3</tt></td> <td class="topAlign">The extra data required to describe a curve in a CurveToElement element.</td> </tr> </table> <p><b>See also</b> <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><b>See also</b> <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 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 class="generic" width="100%"> <tr class="odd" valign="top"> <td><img alt="" src="images/qpainterpath-addellipse.png" /></td> <td> <pre class="cpp"> <span class="type"><a href="qlineargradient.html">QLinearGradient</a></span> myGradient; <span class="type"><a href="qpen.html">QPen</a></span> myPen; <span class="type"><a href="qrectf.html">QRectF</a></span> boundingRectangle; <span class="type"><a href="qpainterpath.html">QPainterPath</a></span> myPath; myPath<span class="operator">.</span>addEllipse(boundingRectangle); <span class="type"><a href="qpainter.html">QPainter</a></span> painter(<span class="keyword">this</span>); painter<span class="operator">.</span>setBrush(myGradient); painter<span class="operator">.</span>setPen(myPen); painter<span class="operator">.</span>drawPath(myPath); </pre></td> </tr> </table> <p><b>See also</b> <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 function.</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="addEllipse-3" />QPainterPath.addEllipse (<i>self</i>, <a href="qpointf.html">QPointF</a> <i>center</i>, float <i>rx</i>, float <i>ry</i>)</h3><p>This is an overloaded function.</p> <p>Creates an ellipse positioned at <i>center</i> with radii <i>rx</i> and <i>ry</i>, and adds it to the painter path as a closed subpath.</p> <p>This function was introduced in Qt 4.4.</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><b>See also</b> <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 class="generic" width="100%"> <tr class="odd" valign="top"> <td><img alt="" src="images/qpainterpath-addpolygon.png" /></td> <td> <pre class="cpp"> <span class="type"><a href="qlineargradient.html">QLinearGradient</a></span> myGradient; <span class="type"><a href="qpen.html">QPen</a></span> myPen; <span class="type"><a href="qpolygonf.html">QPolygonF</a></span> myPolygon; <span class="type"><a href="qpainterpath.html">QPainterPath</a></span> myPath; myPath<span class="operator">.</span>addPolygon(myPolygon); <span class="type"><a href="qpainter.html">QPainter</a></span> painter(<span class="keyword">this</span>); painter<span class="operator">.</span>setBrush(myGradient); painter<span class="operator">.</span>setPen(myPen); painter<span class="operator">.</span>drawPath(myPath); </pre></td> </tr> </table> <p><b>See also</b> <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 class="generic" width="100%"> <tr class="odd" valign="top"> <td><img alt="" src="images/qpainterpath-addrectangle.png" /></td> <td> <pre class="cpp"> <span class="type"><a href="qlineargradient.html">QLinearGradient</a></span> myGradient; <span class="type"><a href="qpen.html">QPen</a></span> myPen; <span class="type"><a href="qrectf.html">QRectF</a></span> myRectangle; <span class="type"><a href="qpainterpath.html">QPainterPath</a></span> myPath; myPath<span class="operator">.</span>addRect(myRectangle); <span class="type"><a href="qpainter.html">QPainter</a></span> painter(<span class="keyword">this</span>); painter<span class="operator">.</span>setBrush(myGradient); painter<span class="operator">.</span>setPen(myPen); painter<span class="operator">.</span>drawPath(myPath); </pre></td> </tr> </table> <p><b>See also</b> <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 function.</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><b>See also</b> <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="addRoundedRect" />QPainterPath.addRoundedRect (<i>self</i>, <a href="qrectf.html">QRectF</a> <i>rect</i>, float <i>xRadius</i>, float <i>yRadius</i>, <a href="qt.html#SizeMode-enum">Qt.SizeMode</a> <i>mode</i> = Qt.AbsoluteSize)</h3><p>Adds the given rectangle <i>rect</i> with rounded corners to the path.</p> <p>The <i>xRadius</i> and <i>yRadius</i> arguments specify the radii of the ellipses defining the corners of the rounded rectangle. When <i>mode</i> is <a href="qt.html#SizeMode-enum">Qt.RelativeSize</a>, <i>xRadius</i> and <i>yRadius</i> are specified in percentage of half the rectangle's width and height respectively, and should be in the range 0.0 to 100.0.</p> <p>This function was introduced in Qt 4.4.</p> <p><b>See also</b> <a href="qpainterpath.html#addRect">addRect</a>().</p> <h3 class="fn"><a name="addRoundedRect-2" />QPainterPath.addRoundedRect (<i>self</i>, float <i>x</i>, float <i>y</i>, float <i>w</i>, float <i>h</i>, float <i>xRadius</i>, float <i>yRadius</i>, <a href="qt.html#SizeMode-enum">Qt.SizeMode</a> <i>mode</i> = Qt.AbsoluteSize)</h3><p>This is an overloaded function.</p> <p>Adds the given rectangle <i>x</i>, <i>y</i>, <i>w</i>, <i>h</i> with rounded corners to the path.</p> <p>This function was introduced in Qt 4.4.</p> <h3 class="fn"><a name="addRoundRect" />QPainterPath.addRoundRect (<i>self</i>, <a href="qrectf.html">QRectF</a> <i>rect</i>, int <i>xRnd</i>, int <i>yRnd</i>)</h3><h3 class="fn"><a name="addRoundRect-2" />QPainterPath.addRoundRect (<i>self</i>, float <i>x</i>, float <i>y</i>, float <i>w</i>, float <i>h</i>, int <i>xRnd</i>, int <i>yRnd</i>)</h3><h3 class="fn"><a name="addRoundRect-3" />QPainterPath.addRoundRect (<i>self</i>, <a href="qrectf.html">QRectF</a> <i>rect</i>, int <i>roundness</i>)</h3><h3 class="fn"><a name="addRoundRect-4" />QPainterPath.addRoundRect (<i>self</i>, float <i>x</i>, float <i>y</i>, float <i>w</i>, float <i>h</i>, int <i>roundness</i>)</h3><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>, QString <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 class="generic" width="100%"> <tr class="odd" valign="top"> <td><img alt="" src="images/qpainterpath-addtext.png" /></td> <td> <pre class="cpp"> <span class="type"><a href="qlineargradient.html">QLinearGradient</a></span> myGradient; <span class="type"><a href="qpen.html">QPen</a></span> myPen; <span class="type"><a href="qfont.html">QFont</a></span> myFont; <span class="type"><a href="qpointf.html">QPointF</a></span> baseline(x<span class="operator">,</span> y); <span class="type"><a href="qpainterpath.html">QPainterPath</a></span> myPath; myPath<span class="operator">.</span>addText(baseline<span class="operator">,</span> myFont<span class="operator">,</span> tr(<span class="string">"Qt"</span>)); <span class="type"><a href="qpainter.html">QPainter</a></span> painter(<span class="keyword">this</span>); painter<span class="operator">.</span>setBrush(myGradient); painter<span class="operator">.</span>setPen(myPen); painter<span class="operator">.</span>drawPath(myPath); </pre></td> </tr> </table> <p><b>See also</b> <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>, QString <i>text</i>)</h3><p>This is an overloaded function.</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="angleAtPercent" />float QPainterPath.angleAtPercent (<i>self</i>, float <i>t</i>)</h3><p>Returns the angle of the path tangent at the percentage <i>t</i>. The argument <i>t</i> has to be between 0 and 1.</p> <p>Positive values for the angles mean counter-clockwise while negative values mean the clockwise direction. Zero degrees is at the 3 o'clock position.</p> <p>Note that similarly to the other percent methods, the percentage measurement is not linear with regards to the length if curves are present in the path. When curves are present the percentage argument is mapped to the t parameter of the Bezier equations.</p> <h3 class="fn"><a name="arcMoveTo" />QPainterPath.arcMoveTo (<i>self</i>, <a href="qrectf.html">QRectF</a> <i>rect</i>, float <i>angle</i>)</h3><p>Creates a move to that lies on the arc that occupies the given <i>rectangle</i> at <i>angle</i>.</p> <p>Angles are specified in degrees. Clockwise arcs can be specified using negative angles.</p> <p>This function was introduced in Qt 4.2.</p> <p><b>See also</b> <a href="qpainterpath.html#moveTo">moveTo</a>() and <a href="qpainterpath.html#arcTo">arcTo</a>().</p> <h3 class="fn"><a name="arcMoveTo-2" />QPainterPath.arcMoveTo (<i>self</i>, float <i>x</i>, float <i>y</i>, float <i>w</i>, float <i>h</i>, float <i>angle</i>)</h3><p>This is an overloaded function.</p> <p>Creates a move to that lies on the arc that occupies the <a href="qrectf.html">QRectF</a>(<i>x</i>, <i>y</i>, <i>width</i>, <i>height</i>) at <i>angle</i>.</p> <p>This function was introduced in Qt 4.2.</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 class="generic" width="100%"> <tr class="odd" valign="top"> <td><img alt="" src="images/qpainterpath-arcto.png" /></td> <td> <pre class="cpp"> <span class="type"><a href="qlineargradient.html">QLinearGradient</a></span> myGradient; <span class="type"><a href="qpen.html">QPen</a></span> myPen; <span class="type"><a href="qpointf.html">QPointF</a></span> center<span class="operator">,</span> startPoint; <span class="type"><a href="qpainterpath.html">QPainterPath</a></span> myPath; myPath<span class="operator">.</span><a href="qpainterpath.html#moveTo">moveTo</a>(center); myPath<span class="operator">.</span>arcTo(boundingRect<span class="operator">,</span> startAngle<span class="operator">,</span> sweepLength); <span class="type"><a href="qpainter.html">QPainter</a></span> painter(<span class="keyword">this</span>); painter<span class="operator">.</span>setBrush(myGradient); painter<span class="operator">.</span>setPen(myPen); painter<span class="operator">.</span>drawPath(myPath); </pre></td> </tr> </table> <p><b>See also</b> <a href="qpainterpath.html#arcMoveTo">arcMoveTo</a>(), <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 function.</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><b>See also</b> <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><b>See also</b> <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><b>See also</b> <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><b>See also</b> <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>Returns true if the given <i>rectangle</i> is inside the path, otherwise returns false.</p> <h3 class="fn"><a name="contains-3" />bool QPainterPath.contains (<i>self</i>, <a href="qpainterpath.html">QPainterPath</a> <i>p</i>)</h3><p>Returns true if the given path <i>p</i> is contained within the current path. Returns false if any edges of the current path and <i>p</i> intersect.</p> <p>Set operations on paths will treat the paths as areas. Non-closed paths will be treated as implicitly closed.</p> <p>This function was introduced in Qt 4.3.</p> <p><b>See also</b> <a href="qpainterpath.html#intersects">intersects</a>().</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><b>See also</b> <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 class="generic" width="100%"> <tr class="odd" valign="top"> <td><img alt="" src="images/qpainterpath-cubicto.png" /></td> <td> <pre class="cpp"> <span class="type"><a href="qlineargradient.html">QLinearGradient</a></span> myGradient; <span class="type"><a href="qpen.html">QPen</a></span> myPen; <span class="type"><a href="qpainterpath.html">QPainterPath</a></span> myPath; myPath<span class="operator">.</span>cubicTo(c1<span class="operator">,</span> c2<span class="operator">,</span> endPoint); <span class="type"><a href="qpainter.html">QPainter</a></span> painter(<span class="keyword">this</span>); painter<span class="operator">.</span>setBrush(myGradient); painter<span class="operator">.</span>setPen(myPen); painter<span class="operator">.</span>drawPath(myPath); </pre></td> </tr> </table> <p><b>See also</b> <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 function.</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><b>See also</b> <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><b>See also</b> <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><b>See also</b> <a href="qpainterpath.html#setFillRule">setFillRule</a>().</p> <h3 class="fn"><a name="intersected" /><a href="qpainterpath.html">QPainterPath</a> QPainterPath.intersected (<i>self</i>, <a href="qpainterpath.html">QPainterPath</a> <i>r</i>)</h3><p>Returns a path which is the intersection of this path's fill area and <i>p</i>'s fill area. Bezier curves may be flattened to line segments due to numerical instability of doing bezier curve intersections.</p> <p>This function was introduced in Qt 4.3.</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> intersects the path; otherwise returns false.</p> <p>There is an intersection if any of the lines making up the rectangle crosses a part of the path or if any part of the rectangle overlaps with any area enclosed by the path. This function respects the current fillRule to determine what is considered inside the path.</p> <p><b>See also</b> <a href="qpainterpath.html#contains">contains</a>().</p> <h3 class="fn"><a name="intersects-2" />bool QPainterPath.intersects (<i>self</i>, <a href="qpainterpath.html">QPainterPath</a> <i>p</i>)</h3><p>Returns true if the current path intersects at any point the given path <i>p</i>. Also returns true if the current path contains or is contained by any part of <i>p</i>.</p> <p>Set operations on paths will treat the paths as areas. Non-closed paths will be treated as implicitly closed.</p> <p>This function was introduced in Qt 4.3.</p> <p><b>See also</b> <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 either there are no elements in this path, or if the only element is a <a href="qpainterpath.html#ElementType-enum">MoveToElement</a>; otherwise returns false.</p> <p><b>See also</b> <a href="qpainterpath.html#elementCount">elementCount</a>().</p> <h3 class="fn"><a name="length" />float QPainterPath.length (<i>self</i>)</h3><p>Returns the length of the current path.</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><b>See also</b> <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 function.</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><b>See also</b> <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 function.</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="percentAtLength" />float QPainterPath.percentAtLength (<i>self</i>, float <i>t</i>)</h3><p>Returns percentage of the whole path at the specified length <i>len</i>.</p> <p>Note that similarly to other percent methods, the percentage measurement is not linear with regards to the length, if curves are present in the path. When curves are present the percentage argument is mapped to the t parameter of the Bezier equations.</p> <h3 class="fn"><a name="pointAtPercent" /><a href="qpointf.html">QPointF</a> QPainterPath.pointAtPercent (<i>self</i>, float <i>t</i>)</h3><p>Returns the point at at the percentage <i>t</i> of the current path. The argument <i>t</i> has to be between 0 and 1.</p> <p>Note that similarly to other percent methods, the percentage measurement is not linear with regards to the length, if curves are present in the path. When curves are present the percentage argument is mapped to the t parameter of the Bezier equations.</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><b>See also</b> <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 function.</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="setElementPositionAt" />QPainterPath.setElementPositionAt (<i>self</i>, int <i>i</i>, float <i>x</i>, float <i>y</i>)</h3><p>Sets the x and y coordinate of the element at index <i>index</i> to <i>x</i> and <i>y</i>.</p> <p>This function was introduced in Qt 4.2.</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 class="generic"> <thead> <tr class="qt-style"> <th><a href="qt.html#FillRule-enum">Qt.OddEvenFill</a> (default)</th> <th><a href="qt.html#FillRule-enum">Qt.WindingFill</a></th> </tr> </thead> <tr class="odd" valign="top"> <td><img alt="" src="images/qt-fillrule-oddeven.png" /></td> <td><img alt="" src="images/qt-fillrule-winding.png" /></td> </tr> </table> <p><b>See also</b> <a href="qpainterpath.html#fillRule">fillRule</a>().</p> <h3 class="fn"><a name="simplified" /><a href="qpainterpath.html">QPainterPath</a> QPainterPath.simplified (<i>self</i>)</h3><p>Returns a simplified version of this path. This implies merging all subpaths that intersect, and returning a path containing no intersecting edges. Consecutive parallel lines will also be merged. The simplified path will always use the default fill rule, <a href="qt.html#FillRule-enum">Qt.OddEvenFill</a>. Bezier curves may be flattened to line segments due to numerical instability of doing bezier curve intersections.</p> <p>This function was introduced in Qt 4.4.</p> <h3 class="fn"><a name="slopeAtPercent" />float QPainterPath.slopeAtPercent (<i>self</i>, float <i>t</i>)</h3><p>Returns the slope of the path at the percentage <i>t</i>. The argument <i>t</i> has to be between 0 and 1.</p> <p>Note that similarly to other percent methods, the percentage measurement is not linear with regards to the length, if curves are present in the path. When curves are present the percentage argument is mapped to the t parameter of the Bezier equations.</p> <h3 class="fn"><a name="subtracted" /><a href="qpainterpath.html">QPainterPath</a> QPainterPath.subtracted (<i>self</i>, <a href="qpainterpath.html">QPainterPath</a> <i>r</i>)</h3><p>Returns a path which is <i>p</i>'s fill area subtracted from this path's fill area.</p> <p>Set operations on paths will treat the paths as areas. Non-closed paths will be treated as implicitly closed. Bezier curves may be flattened to line segments due to numerical instability of doing bezier curve intersections.</p> <p>This function was introduced in Qt 4.3.</p> <h3 class="fn"><a name="subtractedInverted" /><a href="qpainterpath.html">QPainterPath</a> QPainterPath.subtractedInverted (<i>self</i>, <a href="qpainterpath.html">QPainterPath</a> <i>r</i>)</h3><h3 class="fn"><a name="swap" />QPainterPath.swap (<i>self</i>, <a href="qpainterpath.html">QPainterPath</a> <i>other</i>)</h3><p>Swaps painter path <i>other</i> with this painter path. This operation is very fast and never fails.</p> <p>This function was introduced in Qt 4.8.</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 <a href="qtransform.html">QTransform</a> <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><b>See also</b> <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="toFillPolygon-2" /><a href="qpolygonf.html">QPolygonF</a> QPainterPath.toFillPolygon (<i>self</i>, <a href="qtransform.html">QTransform</a> <i>matrix</i>)</h3><p>This is an overloaded function.</p> <h3 class="fn"><a name="toFillPolygons" />list-of-QPolygonF 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 <a href="qtransform.html">QTransform</a> <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><b>See also</b> <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="toFillPolygons-2" />list-of-QPolygonF QPainterPath.toFillPolygons (<i>self</i>, <a href="qtransform.html">QTransform</a> <i>matrix</i>)</h3><p>This is an overloaded function.</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" />list-of-QPolygonF 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 <a href="qtransform.html">QTransform</a> <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><b>See also</b> <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="toSubpathPolygons-2" />list-of-QPolygonF QPainterPath.toSubpathPolygons (<i>self</i>, <a href="qtransform.html">QTransform</a> <i>matrix</i>)</h3><p>This is an overloaded function.</p> <h3 class="fn"><a name="translate" />QPainterPath.translate (<i>self</i>, float <i>dx</i>, float <i>dy</i>)</h3><p>Translates all elements in the path by (<i>dx</i>, <i>dy</i>).</p> <p>This function was introduced in Qt 4.6.</p> <p><b>See also</b> <a href="qpainterpath.html#translated">translated</a>().</p> <h3 class="fn"><a name="translate-2" />QPainterPath.translate (<i>self</i>, <a href="qpointf.html">QPointF</a> <i>offset</i>)</h3><p>This is an overloaded function.</p> <p>Translates all elements in the path by the given <i>offset</i>.</p> <p>This function was introduced in Qt 4.6.</p> <p><b>See also</b> <a href="qpainterpath.html#translated">translated</a>().</p> <h3 class="fn"><a name="translated" /><a href="qpainterpath.html">QPainterPath</a> QPainterPath.translated (<i>self</i>, float <i>dx</i>, float <i>dy</i>)</h3><p>Returns a copy of the path that is translated by (<i>dx</i>, <i>dy</i>).</p> <p>This function was introduced in Qt 4.6.</p> <p><b>See also</b> <a href="qpainterpath.html#translate">translate</a>().</p> <h3 class="fn"><a name="translated-2" /><a href="qpainterpath.html">QPainterPath</a> QPainterPath.translated (<i>self</i>, <a href="qpointf.html">QPointF</a> <i>offset</i>)</h3><p>This is an overloaded function.</p> <p>Returns a copy of the path that is translated by the given <i>offset</i>.</p> <p>This function was introduced in Qt 4.6.</p> <p><b>See also</b> <a href="qpainterpath.html#translate">translate</a>().</p> <h3 class="fn"><a name="united" /><a href="qpainterpath.html">QPainterPath</a> QPainterPath.united (<i>self</i>, <a href="qpainterpath.html">QPainterPath</a> <i>r</i>)</h3><p>Returns a path which is the union of this path's fill area and <i>p</i>'s fill area.</p> <p>Set operations on paths will treat the paths as areas. Non-closed paths will be treated as implicitly closed. Bezier curves may be flattened to line segments due to numerical instability of doing bezier curve intersections.</p> <p>This function was introduced in Qt 4.3.</p> <p><b>See also</b> <a href="qpainterpath.html#intersected">intersected</a>() and <a href="qpainterpath.html#subtracted">subtracted</a>().</p> <h3 class="fn"><a name="__add__" /><a href="qpainterpath.html">QPainterPath</a> QPainterPath.__add__ (<i>self</i>, <a href="qpainterpath.html">QPainterPath</a> <i>other</i>)</h3><h3 class="fn"><a name="__and__" /><a href="qpainterpath.html">QPainterPath</a> QPainterPath.__and__ (<i>self</i>, <a href="qpainterpath.html">QPainterPath</a> <i>other</i>)</h3><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="__iadd__" /><a href="qpainterpath.html">QPainterPath</a> QPainterPath.__iadd__ (<i>self</i>, <a href="qpainterpath.html">QPainterPath</a> <i>other</i>)</h3><h3 class="fn"><a name="__iand__" /><a href="qpainterpath.html">QPainterPath</a> QPainterPath.__iand__ (<i>self</i>, <a href="qpainterpath.html">QPainterPath</a> <i>other</i>)</h3><h3 class="fn"><a name="__ior__" /><a href="qpainterpath.html">QPainterPath</a> QPainterPath.__ior__ (<i>self</i>, <a href="qpainterpath.html">QPainterPath</a> <i>other</i>)</h3><h3 class="fn"><a name="__isub__" /><a href="qpainterpath.html">QPainterPath</a> QPainterPath.__isub__ (<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="__mul__-2" /><a href="qpainterpath.html">QPainterPath</a> QPainterPath.__mul__ (<i>self</i>, <a href="qtransform.html">QTransform</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><h3 class="fn"><a name="__or__" /><a href="qpainterpath.html">QPainterPath</a> QPainterPath.__or__ (<i>self</i>, <a href="qpainterpath.html">QPainterPath</a> <i>other</i>)</h3><h3 class="fn"><a name="__sub__" /><a href="qpainterpath.html">QPainterPath</a> QPainterPath.__sub__ (<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 align="left" width="25%">PyQt 4.10.3 for X11</td><td align="center" width="50%">Copyright © <a href="http://www.riverbankcomputing.com">Riverbank Computing Ltd</a> and <a href="http://www.qtsoftware.com">Nokia</a> 2012</td><td align="right" width="25%">Qt 4.8.5</td></tr></table></div></address></body></html>