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
|
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en_US" lang="en_US">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- qdeclarativerectangle.cpp -->
<title>Qt 4.8: QML Gradient Element</title>
<link rel="stylesheet" type="text/css" href="style/offline.css" />
</head>
<body>
<div class="header" id="qtdocheader">
<div class="content">
<a href="index.html" class="qtref"><span>Qt Reference Documentation</span></a>
</div>
<div class="breadcrumb toolblock">
<ul>
<li class="first"><a href="index.html">Home</a></li>
<!-- Breadcrumbs go here -->
<li><a href="qdeclarativeelements.html">QML Elements</a></li>
<li>QML Gradient Element</li>
</ul>
</div>
</div>
<div class="content mainContent">
<div class="toc">
<h3><a name="toc">Contents</a></h3>
<ul>
<li class="level1"><a href="#properties">Properties</a></li>
<li class="level1"><a href="#details">Detailed Description</a></li>
<li class="level2"><a href="#example-usage">Example Usage</a></li>
<li class="level2"><a href="#performance-and-limitations">Performance and Limitations</a></li>
</ul>
</div>
<h1 class="title">QML Gradient Element</h1>
<span class="subtitle"></span>
<!-- $$$Gradient-brief -->
<p>The Gradient item defines a gradient fill. <a href="#details">More...</a></p>
<!-- @@@Gradient -->
<p>This element was introduced in Qt 4.7.</p>
<ul>
<li><a href="qml-gradient-members.html">List of all members, including inherited members</a></li>
</ul>
<a name="properties"></a>
<h2>Properties</h2>
<ul>
<li class="fn"><b><b><a href="qml-gradient.html#stops-prop">stops</a></b></b> : list<GradientStop></li>
</ul>
<!-- $$$Gradient-description -->
<a name="details"></a>
<h2>Detailed Description</h2>
<p>A gradient is defined by two or more colors, which will be blended seamlessly.</p>
<p>The colors are specified as a set of <a href="qml-gradientstop.html">GradientStop</a> child items, each of which defines a position on the gradient from 0.0 to 1.0 and a color. The position of each <a href="qml-gradientstop.html">GradientStop</a> is defined by setting its <a href="qml-gradientstop.html#position-prop">position</a> property; its color is defined using its <a href="qml-gradientstop.html#color-prop">color</a> property.</p>
<p>A gradient without any gradient stops is rendered as a solid white fill.</p>
<p>Note that this item is not a visual representation of a gradient. To display a gradient, use a visual element (like <a href="qml-rectangle.html">Rectangle</a>) which supports the use of gradients.</p>
<a name="example-usage"></a>
<h2>Example Usage</h2>
<div class="float-right"><p><img src="images/qml-gradient.png" alt="" /></p>
</div><p>The following example declares a <a href="qml-rectangle.html">Rectangle</a> item with a gradient starting with red, blending to yellow at one third of the height of the rectangle, and ending with green:</p>
<pre class="qml"> <span class="type"><a href="qml-rectangle.html">Rectangle</a></span> {
<span class="name">width</span>: <span class="number">100</span>; <span class="name">height</span>: <span class="number">100</span>
<span class="name">gradient</span>: <span class="name">Gradient</span> {
<span class="type"><a href="qml-gradientstop.html">GradientStop</a></span> { <span class="name">position</span>: <span class="number">0.0</span>; <span class="name">color</span>: <span class="string">"red"</span> }
<span class="type"><a href="qml-gradientstop.html">GradientStop</a></span> { <span class="name">position</span>: <span class="number">0.33</span>; <span class="name">color</span>: <span class="string">"yellow"</span> }
<span class="type"><a href="qml-gradientstop.html">GradientStop</a></span> { <span class="name">position</span>: <span class="number">1.0</span>; <span class="name">color</span>: <span class="string">"green"</span> }
}
}</pre>
<br style="clear: both" /><a name="performance-and-limitations"></a>
<h2>Performance and Limitations</h2>
<p>Calculating gradients can be computationally expensive compared to the use of solid color fills or images. Consider using gradients for static items in a user interface.</p>
<p>In Qt 4.7, only vertical, linear gradients can be applied to items. If you need to apply different orientations of gradients, a combination of rotation and clipping will need to be applied to the relevant items. This can introduce additional performance requirements for your application.</p>
<p>The use of animations involving gradient stops may not give the desired result. An alternative way to animate gradients is to use pre-generated images or SVG drawings containing gradients.</p>
<p><b>See also </b><a href="qml-gradientstop.html">GradientStop</a>.</p>
<!-- @@@Gradient -->
<h2>Property Documentation</h2>
<!-- $$$stops -->
<div class="qmlitem"><div class="qmlproto"><table class="qmlname"><tr valign="top" class="odd"><td class="tblQmlPropNode"><p><a name="stops-prop"></a><span class="qmlreadonly">read-only</span><span class="name">stops</span> : <span class="type"><a href="qml-list.html">list</a></span><<span class="type"><a href="qml-gradientstop.html">GradientStop</a></span>></p></td></tr></table></div><div class="qmldoc"><p>This property holds the gradient stops describing the gradient.</p>
<p>By default, this property contains an empty list.</p>
<p>To set the gradient stops, define them as children of the Gradient element.</p>
</div></div><!-- @@@stops -->
<br/>
<div class="ft">
<span></span>
</div>
</div>
<div class="footer">
<p>
<acronym title="Copyright">©</acronym> 2012 Nokia Corporation and/or its
subsidiaries. Documentation contributions included herein are the copyrights of
their respective owners.</p>
<br />
<p>
The documentation provided herein is licensed under the terms of the
<a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation
License version 1.3</a> as published by the Free Software Foundation.</p>
<p>
Documentation sources may be obtained from <a href="http://www.qt-project.org">
www.qt-project.org</a>.</p>
<br />
<p>
Nokia, Qt and their respective logos are trademarks of Nokia Corporation
in Finland and/or other countries worldwide. All other trademarks are property
of their respective owners. <a title="Privacy Policy"
href="http://en.gitorious.org/privacy_policy/">Privacy Policy</a></p>
</div>
</body>
</html>
|