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
|
<?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>QGradient 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">QGradient Class Reference<br /><sup><sup>[<a href="qtgui.html">QtGui</a> module]</sup></sup></h1><p>The QGradient class is used in combination with <a href="qbrush.html">QBrush</a> to specify gradient fills. <a href="#details">More...</a></p>
<p>Inherited by <a href="qconicalgradient.html">QConicalGradient</a>, <a href="qlineargradient.html">QLinearGradient</a> and <a href="qradialgradient.html">QRadialGradient</a>.</p><h3>Types</h3><ul><li><div class="fn" />enum <b><a href="qgradient.html#Spread-enum">Spread</a></b> { PadSpread, ReflectSpread, RepeatSpread }</li><li><div class="fn" />enum <b><a href="qgradient.html#Type-enum">Type</a></b> { LinearGradient, RadialGradient, ConicalGradient, NoGradient }</li></ul><h3>Methods</h3><ul><li><div class="fn" /><b><a href="qgradient.html#QGradient">__init__</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qgradient.html#QGradient-2">__init__</a></b> (<i>self</i>, QGradient)</li><li><div class="fn" /><b><a href="qgradient.html#setColorAt">setColorAt</a></b> (<i>self</i>, float <i>pos</i>, QColor <i>color</i>)</li><li><div class="fn" /><b><a href="qgradient.html#setSpread">setSpread</a></b> (<i>self</i>, Spread <i>aspread</i>)</li><li><div class="fn" /><b><a href="qgradient.html#setStops">setStops</a></b> (<i>self</i>, float-QColor-tuple-list <i>stops</i>)</li><li><div class="fn" />Spread <b><a href="qgradient.html#spread">spread</a></b> (<i>self</i>)</li><li><div class="fn" />float-QColor-tuple-list <b><a href="qgradient.html#stops">stops</a></b> (<i>self</i>)</li><li><div class="fn" />Type <b><a href="qgradient.html#type">type</a></b> (<i>self</i>)</li></ul><h3>Special Methods</h3><ul><li><div class="fn" />bool <b><a href="qgradient.html#__eq__">__eq__</a></b> (<i>self</i>, QGradient <i>gradient</i>)</li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>The QGradient class is used in combination with <a href="qbrush.html">QBrush</a> to specify gradient fills.</p>
<p>Qt currently supports three types of gradient fills:</p>
<ul>
<li><i>Linear</i> gradients interpolate colors between start and end points.</li>
<li><i>Radial</i> gradients interpolate colors between a focal point and end points on a circle surrounding it.</li>
<li><i>Conical</i> gradients interpolate colors around a center point.</li>
</ul>
<p>A gradient's type can be retrieved using the <a href="qgradient.html#type">type</a>() function. Each of the types is represented by a subclass of QGradient:</p>
<table align="center" border="0" cellpadding="2" cellspacing="1">
<tr bgcolor="#F0F0F0" valign="top">
<td><img src="images/qgradient-linear.png" /></td>
<td><img src="images/qgradient-radial.png" /></td>
<td><img src="images/qgradient-conical.png" /></td>
</tr>
<tr bgcolor="#A2C511" valign="top">
<th><a href="qlineargradient.html">QLinearGradient</a></th>
<th><a href="qradialgradient.html">QRadialGradient</a></th>
<th><a href="qconicalgradient.html">QConicalGradient</a></th>
</tr>
</table>
<br />
<br />
<p>The colors in a gradient is defined using stop points of the <a href="qgradient.html#QGradientStop-typedef">QGradientStop</a> type, i.e. a position and a color. Use the <a href="qgradient.html#setColorAt">setColorAt</a>() function to define a single stop point. Alternatively, use the <a href="qgradient.html#setStops">setStops</a>() function to define several stop points in one go. Note that the latter function <i>replaces</i> the current set of stop points.</p>
<p>It is the gradient's complete set of stop points (accessible through the <a href="qgradient.html#stops">stops</a>() function) that describes how the gradient area should be filled. If no stop points have been specified, a gradient of black at 0 to white at 1 is used.</p>
<p>A diagonal linear gradient from black at (100, 100) to white at (200, 200) could be specified like this:</p>
<pre>
QLinearGradient linearGrad(QPointF(100, 100), QPointF(200, 200));
linearGrad.setColorAt(0, Qt.black);
linearGrad.setColorAt(1, Qt.white);
</pre>
<p>A gradient can have an arbitrary number of stop points. The following would create a radial gradient starting with red in the center, blue and then green on the edges:</p>
<pre>
QRadialGradient radialGrad(QPointF(100, 100), 100);
radialGrad.setColorAt(0, Qt.red);
radialGrad.setColorAt(0.5, Qt.blue);
radialGrad.setColorAt(1, Qt.green);
</pre>
<p>It is possible to repeat or reflect the gradient outside its area by specifiying the <a href="qgradient.html#Spread-enum">spread method</a> using the <a href="qgradient.html#setSpread">setSpread</a>() function. The default is to pad the outside area with the color at the closest stop point. The currently set <a href="qgradient.html#Spread-enum">spread method</a> can be retrieved using the <a href="qgradient.html#spread">spread</a>() function. The <a href="qgradient.html#Spread-enum">QGradient.Spread</a> enum defines three different methods:</p>
<table align="center" border="0" cellpadding="2" cellspacing="1">
<tr bgcolor="#F0F0F0" valign="top">
<td><img src="images/qradialgradient-pad.png" /></td>
<td><img src="images/qradialgradient-repeat.png" /></td>
<td><img src="images/qradialgradient-reflect.png" /></td>
</tr>
<tr bgcolor="#E0E0E0" valign="top">
<td><a href="qgradient.html#Spread-enum">PadSpread</a></td>
<td><a href="qgradient.html#Spread-enum">RepeatSpread</a></td>
<td><a href="qgradient.html#Spread-enum">ReflectSpread</a></td>
</tr>
</table>
<br />
<br />
<p>Note that the <a href="qgradient.html#setSpread">setSpread</a>() function only has effect for linear and radial gradients. The reason is that the conical gradient is closed by definition, i.e. the <i>conical</i> gradient fills the entire circle from 0 - 360 degrees, while the boundary of a radial or a linear gradient can be specified through its radius or final stop points, respectively.</p>
<p>See also <a href="demos-gradients.html">The Gradients Demo</a> and <a href="qbrush.html">QBrush</a>.</p>
<hr /><h2>Type Documentation</h2><h3 class="fn"><a name="Spread-enum" />QGradient.Spread</h3><p>Specifies how the area outside the gradient area should be filled.</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>QGradient.PadSpread</tt></td>
<td align="center" valign="top"><tt>0</tt></td>
<td valign="top">The area is filled with the closest stop color. This is the default.</td>
</tr>
<tr>
<td valign="top"><tt>QGradient.RepeatSpread</tt></td>
<td align="center" valign="top"><tt>2</tt></td>
<td valign="top">The gradient is repeated outside the gradient area.</td>
</tr>
<tr>
<td valign="top"><tt>QGradient.ReflectSpread</tt></td>
<td align="center" valign="top"><tt>1</tt></td>
<td valign="top">The gradient is reflected outside the gradient area.</td>
</tr>
</table>
<br />
<br />
<p>See also <a href="qgradient.html#spread">spread</a>() and <a href="qgradient.html#setSpread">setSpread</a>().</p>
<h3 class="fn"><a name="Type-enum" />QGradient.Type</h3><p>Specifies the type of gradient.</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>QGradient.LinearGradient</tt></td>
<td align="center" valign="top"><tt>0</tt></td>
<td valign="top">Interpolates colors between start and end points (<a href="qlineargradient.html">QLinearGradient</a>).</td>
</tr>
<tr>
<td valign="top"><tt>QGradient.RadialGradient</tt></td>
<td align="center" valign="top"><tt>1</tt></td>
<td valign="top">Interpolate colors between a focal point and end points on a circle surrounding it (<a href="qradialgradient.html">QRadialGradient</a>).</td>
</tr>
<tr>
<td valign="top"><tt>QGradient.ConicalGradient</tt></td>
<td align="center" valign="top"><tt>2</tt></td>
<td valign="top">Interpolate colors around a center point (<a href="qconicalgradient.html">QConicalGradient</a>).</td>
</tr>
<tr>
<td valign="top"><tt>QGradient.NoGradient</tt></td>
<td align="center" valign="top"><tt>3</tt></td>
<td valign="top">No gradient is used.</td>
</tr>
</table>
<br />
<br />
<p>See also <a href="qgradient.html#type">type</a>().</p>
<hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QGradient" />QGradient.__init__ (<i>self</i>)</h3><h3 class="fn"><a name="QGradient-2" />QGradient.__init__ (<i>self</i>, <a href="qgradient.html">QGradient</a>)</h3><h3 class="fn"><a name="setColorAt" />QGradient.setColorAt (<i>self</i>, float <i>pos</i>, <a href="qcolor.html">QColor</a> <i>color</i>)</h3><p>Creates a stop point at the given <i>position</i> with the given <i>color</i>. The given <i>position</i> must be in the range 0 to 1.</p>
<p>See also <a href="qgradient.html#setStops">setStops</a>() and <a href="qgradient.html#stops">stops</a>().</p>
<h3 class="fn"><a name="setSpread" />QGradient.setSpread (<i>self</i>, <a href="qgradient.html#Spread-enum">Spread</a> <i>aspread</i>)</h3><p>Specifies the spread <i>method</i> that should be used for this gradient.</p>
<p>Note that this function only has effect for linear and radial gradients.</p>
<p>See also <a href="qgradient.html#spread">spread</a>().</p>
<h3 class="fn"><a name="setStops" />QGradient.setStops (<i>self</i>, float-QColor-tuple-list <i>stops</i>)</h3><p>Replaces the current set of stop points with the given <i>stopPoints</i>. The positions of the points must be in the range 0 to 1, and must be sorted with the lowest point first.</p>
<p>See also <a href="qgradient.html#setColorAt">setColorAt</a>() and <a href="qgradient.html#stops">stops</a>().</p>
<h3 class="fn"><a name="spread" /><a href="qgradient.html#Spread-enum">Spread</a> QGradient.spread (<i>self</i>)</h3><p>Returns the spread method use by this gradient. The default is <a href="qgradient.html#Spread-enum">PadSpread</a>.</p>
<p>See also <a href="qgradient.html#setSpread">setSpread</a>().</p>
<h3 class="fn"><a name="stops" />float-QColor-tuple-list QGradient.stops (<i>self</i>)</h3><p>Returns the stop points for this gradient.</p>
<p>If no stop points have been specified, a gradient of black at 0 to white at 1 is used.</p>
<p>See also <a href="qgradient.html#setStops">setStops</a>() and <a href="qgradient.html#setColorAt">setColorAt</a>().</p>
<h3 class="fn"><a name="type" /><a href="qgradient.html#Type-enum">Type</a> QGradient.type (<i>self</i>)</h3><p>Returns the type of gradient.</p>
<h3 class="fn"><a name="__eq__" />bool QGradient.__eq__ (<i>self</i>, <a href="qgradient.html">QGradient</a> <i>gradient</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>
|