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
|
<?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" />
<!-- qdeclarativeborderimage.cpp -->
<title>Qt 4.8: QML BorderImage 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 BorderImage Element</li>
</ul>
</div>
</div>
<div class="content mainContent">
<p class="naviNextPrevious headerNavi">
</p><p/>
<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="#quality-and-performance">Quality and Performance</a></li>
</ul>
</div>
<h1 class="title">QML BorderImage Element</h1>
<span class="subtitle"></span>
<!-- $$$BorderImage-brief -->
<p>The BorderImage element provides an image that can be used as a border. <a href="#details">More...</a></p>
<!-- @@@BorderImage -->
<p>Inherits <a href="qml-item.html">Item</a></p>
<p>This element was introduced in Qt 4.7.</p>
<ul>
<li><a href="qml-borderimage-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-borderimage.html#asynchronous-prop">asynchronous</a></b></b> : bool</li>
<li class="fn"><b><b><a href="qml-borderimage.html#border.bottom-prop">border.bottom</a></b></b> : int</li>
<li class="fn"><b><b><a href="qml-borderimage.html#border.left-prop">border.left</a></b></b> : int</li>
<li class="fn"><b><b><a href="qml-borderimage.html#border.right-prop">border.right</a></b></b> : int</li>
<li class="fn"><b><b><a href="qml-borderimage.html#border.top-prop">border.top</a></b></b> : int</li>
<li class="fn"><b><b><a href="qml-borderimage.html#cache-prop">cache</a></b></b> : bool</li>
<li class="fn"><b><b><a href="qml-borderimage.html#horizontalTileMode-prop">horizontalTileMode</a></b></b> : enumeration</li>
<li class="fn"><b><b><a href="qml-borderimage.html#mirror-prop">mirror</a></b></b> : bool</li>
<li class="fn"><b><b><a href="qml-borderimage.html#progress-prop">progress</a></b></b> : real</li>
<li class="fn"><b><b><a href="qml-borderimage.html#smooth-prop">smooth</a></b></b> : bool</li>
<li class="fn"><b><b><a href="qml-borderimage.html#source-prop">source</a></b></b> : url</li>
<li class="fn"><b><b><a href="qml-borderimage.html#sourceSize-prop">sourceSize</a></b></b> : QSize</li>
<li class="fn"><b><b><a href="qml-borderimage.html#status-prop">status</a></b></b> : enumeration</li>
<li class="fn"><b><b><a href="qml-borderimage.html#verticalTileMode-prop">verticalTileMode</a></b></b> : enumeration</li>
</ul>
<!-- $$$BorderImage-description -->
<a name="details"></a>
<h2>Detailed Description</h2>
<p>The BorderImage element is used to create borders out of images by scaling or tiling parts of each image.</p>
<p>A BorderImage element breaks a source image, specified using the <a href="qml-url.html">url</a> property, into 9 regions, as shown below:</p>
<p class="centerAlign"><img src="images/declarative-scalegrid.png" alt="" /></p><p>When the image is scaled, regions of the source image are scaled or tiled to create the displayed border image in the following way:</p>
<ul>
<li>The corners (regions 1, 3, 7, and 9) are not scaled at all.</li>
<li>Regions 2 and 8 are scaled according to <a href="qml-borderimage.html#horizontalTileMode-prop">horizontalTileMode</a>.</li>
<li>Regions 4 and 6 are scaled according to <a href="qml-borderimage.html#verticalTileMode-prop">verticalTileMode</a>.</li>
<li>The middle (region 5) is scaled according to both <a href="qml-borderimage.html#horizontalTileMode-prop">horizontalTileMode</a> and <a href="qml-borderimage.html#verticalTileMode-prop">verticalTileMode</a>.</li>
</ul>
<p>The regions of the image are defined using the <a href="stylesheet-reference.html#border">border</a> property group, which describes the distance from each edge of the source image to use as a border.</p>
<a name="example-usage"></a>
<h2>Example Usage</h2>
<p>The following examples show the effects of the different modes on an image. Guide lines are overlaid onto the image to show the different regions of the image as described above.</p>
<div style="float: left; margin-right: 2em"><p class="centerAlign"><img src="images/qml-borderimage-normal-image.png" alt="" /></p></div><p>An unscaled image is displayed using an Image element. The <a href="stylesheet-reference.html#border">border</a> property is used to determine the parts of the image that will lie inside the unscaled corner areas and the parts that will be stretched horizontally and vertically.</p>
<pre class="qml"> <span class="type"><a href="qml-image.html">Image</a></span> {
<span class="name">source</span>: <span class="string">"pics/borderframe.png"</span>
}</pre>
<br style="clear: both" /><div style="float: left; margin-right: 2em"><p class="centerAlign"><img src="images/qml-borderimage-scaled.png" alt="" /></p></div><p>A BorderImage element is used to display the image, and it is given a size that is larger than the original image. Since the <a href="qml-borderimage.html#horizontalTileMode-prop">horizontalTileMode</a> property is set to <a href="qml-borderimage.html#horizontalTileMode-prop">BorderImage.Stretch</a>, the parts of image in regions 2 and 8 are stretched horizontally. Since the <a href="qml-borderimage.html#verticalTileMode-prop">verticalTileMode</a> property is set to <a href="qml-borderimage.html#verticalTileMode-prop">BorderImage.Stretch</a>, the parts of image in regions 4 and 6 are stretched vertically.</p>
<pre class="qml"> <span class="type">BorderImage</span> {
<span class="name">width</span>: <span class="number">180</span>; <span class="name">height</span>: <span class="number">180</span>
<span class="type">border</span> { <span class="name">left</span>: <span class="number">30</span>; <span class="name">top</span>: <span class="number">30</span>; <span class="name">right</span>: <span class="number">30</span>; <span class="name">bottom</span>: <span class="number">30</span> }
<span class="name">horizontalTileMode</span>: <span class="name">BorderImage</span>.<span class="name">Stretch</span>
<span class="name">verticalTileMode</span>: <span class="name">BorderImage</span>.<span class="name">Stretch</span>
<span class="name">source</span>: <span class="string">"pics/borderframe.png"</span>
}</pre>
<br style="clear: both" /><div style="float: left; margin-right: 2em"><p class="centerAlign"><img src="images/qml-borderimage-tiled.png" alt="" /></p></div><p>Again, a large BorderImage element is used to display the image. With the <a href="qml-borderimage.html#horizontalTileMode-prop">horizontalTileMode</a> property set to <a href="qml-borderimage.html#horizontalTileMode-prop">BorderImage.Repeat</a>, the parts of image in regions 2 and 8 are tiled so that they fill the space at the top and bottom of the element. Similarly, the <a href="qml-borderimage.html#verticalTileMode-prop">verticalTileMode</a> property is set to <a href="qml-borderimage.html#verticalTileMode-prop">BorderImage.Repeat</a>, the parts of image in regions 4 and 6 are tiled so that they fill the space at the left and right of the element.</p>
<pre class="qml"> <span class="type">BorderImage</span> {
<span class="name">width</span>: <span class="number">180</span>; <span class="name">height</span>: <span class="number">180</span>
<span class="type">border</span> { <span class="name">left</span>: <span class="number">30</span>; <span class="name">top</span>: <span class="number">30</span>; <span class="name">right</span>: <span class="number">30</span>; <span class="name">bottom</span>: <span class="number">30</span> }
<span class="name">horizontalTileMode</span>: <span class="name">BorderImage</span>.<span class="name">Repeat</span>
<span class="name">verticalTileMode</span>: <span class="name">BorderImage</span>.<span class="name">Repeat</span>
<span class="name">source</span>: <span class="string">"pics/borderframe.png"</span>
}</pre>
<br style="clear: both" /><p>In some situations, the width of regions 2 and 8 may not be an exact multiple of the width of the corresponding regions in the source image. Similarly, the height of regions 4 and 6 may not be an exact multiple of the height of the corresponding regions. It can be useful to use <a href="qml-borderimage.html#horizontalTileMode-prop">BorderImage.Round</a> instead of <a href="qml-borderimage.html#horizontalTileMode-prop">BorderImage.Repeat</a> in cases like these.</p>
<p>The <a href="declarative-imageelements-borderimage.html">BorderImage example</a> shows how a BorderImage can be used to simulate a shadow effect on a rectangular item.</p>
<a name="quality-and-performance"></a>
<h2>Quality and Performance</h2>
<p>By default, any scaled regions of the image are rendered without smoothing to improve rendering speed. Setting the <a href="qml-borderimage.html#smooth-prop">smooth</a> property improves rendering quality of scaled regions, but may slow down rendering.</p>
<p>The source image may not be loaded instantaneously, depending on its original location. Loading progress can be monitored with the <a href="qml-borderimage.html#progress-prop">progress</a> property.</p>
<p><b>See also </b><a href="qml-image.html">Image</a> and <a href="qml-animatedimage.html">AnimatedImage</a>.</p>
<!-- @@@BorderImage -->
<h2>Property Documentation</h2>
<!-- $$$asynchronous -->
<div class="qmlitem"><div class="qmlproto"><table class="qmlname"><tr valign="top" class="odd"><td class="tblQmlPropNode"><p><a name="asynchronous-prop"></a><span class="name">asynchronous</span> : <span class="type"><a href="qml-bool.html">bool</a></span></p></td></tr></table></div><div class="qmldoc"><p>Specifies that images on the local filesystem should be loaded asynchronously in a separate thread. The default value is false, causing the user interface thread to block while the image is loaded. Setting <i>asynchronous</i> to true is useful where maintaining a responsive user interface is more desirable than having images immediately visible.</p>
<p>Note that this property is only valid for images read from the local filesystem. Images loaded via a network resource (e.g. HTTP) are always loaded asynchonously.</p>
</div></div><!-- @@@asynchronous -->
<br/>
<!-- $$$border.left -->
<div class="qmlitem"><div class="qmlproto"><table class="qmlname"><tr valign="top" class="odd"><td class="tblQmlPropNode"><p><a name="border.left-prop"></a><span class="name">border.left</span> : <span class="type"><a href="qml-int.html">int</a></span></p></td></tr><tr valign="top" class="even"><td class="tblQmlPropNode"><p><a name="border.right-prop"></a><span class="name">border.right</span> : <span class="type"><a href="qml-int.html">int</a></span></p></td></tr><tr valign="top" class="odd"><td class="tblQmlPropNode"><p><a name="border.top-prop"></a><span class="name">border.top</span> : <span class="type"><a href="qml-int.html">int</a></span></p></td></tr><tr valign="top" class="even"><td class="tblQmlPropNode"><p><a name="border.bottom-prop"></a><span class="name">border.bottom</span> : <span class="type"><a href="qml-int.html">int</a></span></p></td></tr></table></div><div class="qmldoc"><p>The 4 border lines (2 horizontal and 2 vertical) break the image into 9 sections, as shown below:</p>
<p class="centerAlign"><img src="images/declarative-scalegrid.png" alt="" /></p><p>Each border line (left, right, top, and bottom) specifies an offset in pixels from the respective edge of the source image. By default, each border line has a value of 0.</p>
<p>For example, the following definition sets the bottom line 10 pixels up from the bottom of the image:</p>
<pre class="qml"> <span class="type"><a href="qml-borderimage.html">BorderImage</a></span> {
<span class="name">border</span>.bottom: <span class="number">10</span>
<span class="comment">// ...</span>
}</pre>
<p>The border lines can also be specified using a <a href="qml-borderimage.html#source-prop">.sci file</a>.</p>
</div></div><!-- @@@border.left -->
<br/>
<!-- $$$cache -->
<div class="qmlitem"><div class="qmlproto"><table class="qmlname"><tr valign="top" class="odd"><td class="tblQmlPropNode"><p><a name="cache-prop"></a><span class="name">cache</span> : <span class="type"><a href="qml-bool.html">bool</a></span></p></td></tr></table></div><div class="qmldoc"><p>Specifies whether the image should be cached. The default value is true. Setting <i>cache</i> to false is useful when dealing with large images, to make sure that they aren't cached at the expense of small 'ui element' images.</p>
<p>This property group was introduced in QtQuick 1.1.</p>
</div></div><!-- @@@cache -->
<br/>
<!-- $$$horizontalTileMode -->
<div class="qmlitem"><div class="qmlproto"><table class="qmlname"><tr valign="top" class="odd"><td class="tblQmlPropNode"><p><a name="horizontalTileMode-prop"></a><span class="name">horizontalTileMode</span> : <span class="type"><a href="qml-enumeration.html">enumeration</a></span></p></td></tr><tr valign="top" class="even"><td class="tblQmlPropNode"><p><a name="verticalTileMode-prop"></a><span class="name">verticalTileMode</span> : <span class="type"><a href="qml-enumeration.html">enumeration</a></span></p></td></tr></table></div><div class="qmldoc"><p>This property describes how to repeat or stretch the middle parts of the border image.</p>
<ul>
<li><a href="qml-borderimage.html">BorderImage</a>.Stretch - Scales the image to fit to the available area.</li>
<li><a href="qml-borderimage.html">BorderImage</a>.Repeat - Tile the image until there is no more space. May crop the last image.</li>
<li><a href="qml-borderimage.html">BorderImage</a>.Round - Like Repeat, but scales the images down to ensure that the last image is not cropped.</li>
</ul>
<p>The default tile mode for each property is <a href="qml-borderimage.html">BorderImage</a>.Stretch.</p>
</div></div><!-- @@@horizontalTileMode -->
<br/>
<!-- $$$mirror -->
<div class="qmlitem"><div class="qmlproto"><table class="qmlname"><tr valign="top" class="odd"><td class="tblQmlPropNode"><p><a name="mirror-prop"></a><span class="name">mirror</span> : <span class="type"><a href="qml-bool.html">bool</a></span></p></td></tr></table></div><div class="qmldoc"><p>This property holds whether the image should be horizontally inverted (effectively displaying a mirrored image).</p>
<p>The default value is false.</p>
<p>This property group was introduced in QtQuick 1.1.</p>
</div></div><!-- @@@mirror -->
<br/>
<!-- $$$progress -->
<div class="qmlitem"><div class="qmlproto"><table class="qmlname"><tr valign="top" class="odd"><td class="tblQmlPropNode"><p><a name="progress-prop"></a><span class="qmlreadonly">read-only</span><span class="name">progress</span> : <span class="type"><a href="qml-real.html">real</a></span></p></td></tr></table></div><div class="qmldoc"><p>This property holds the progress of image loading, from 0.0 (nothing loaded) to 1.0 (finished).</p>
<p><b>See also </b><a href="qml-borderimage.html#status-prop">status</a>.</p>
</div></div><!-- @@@progress -->
<br/>
<!-- $$$smooth -->
<div class="qmlitem"><div class="qmlproto"><table class="qmlname"><tr valign="top" class="odd"><td class="tblQmlPropNode"><p><a name="smooth-prop"></a><span class="name">smooth</span> : <span class="type"><a href="qml-bool.html">bool</a></span></p></td></tr></table></div><div class="qmldoc"><p>Set this property if you want the image to be smoothly filtered when scaled or transformed. Smooth filtering gives better visual quality, but is slower. If the image is displayed at its natural size, this property has no visual or performance effect.</p>
<p>By default, this property is set to false.</p>
<p><b>Note:</b> Generally scaling artifacts are only visible if the image is stationary on the screen. A common pattern when animating an image is to disable smooth filtering at the beginning of the animation and enable it at the conclusion.</p>
</div></div><!-- @@@smooth -->
<br/>
<!-- $$$source -->
<div class="qmlitem"><div class="qmlproto"><table class="qmlname"><tr valign="top" class="odd"><td class="tblQmlPropNode"><p><a name="source-prop"></a><span class="name">source</span> : <span class="type"><a href="qml-url.html">url</a></span></p></td></tr></table></div><div class="qmldoc"><p>This property holds the URL that refers to the source image.</p>
<p><a href="qml-borderimage.html">BorderImage</a> can handle any image format supported by Qt, loaded from any URL scheme supported by Qt.</p>
<p>This property can also be used to refer to .sci files, which are written in a QML-specific, text-based format that specifies the borders, the image file and the tile rules for a given border image.</p>
<p>The following .sci file sets the borders to 10 on each side for the image <tt>picture.png</tt>:</p>
<pre class="cpp"> border<span class="operator">.</span>left: <span class="number">10</span>
border<span class="operator">.</span>top: <span class="number">10</span>
border<span class="operator">.</span>bottom: <span class="number">10</span>
border<span class="operator">.</span>right: <span class="number">10</span>
source: <span class="string">"picture.png"</span></pre>
<p>The URL may be absolute, or relative to the URL of the component.</p>
<p><b>See also </b><a href="qdeclarativeimageprovider.html">QDeclarativeImageProvider</a>.</p>
</div></div><!-- @@@source -->
<br/>
<!-- $$$sourceSize -->
<div class="qmlitem"><div class="qmlproto"><table class="qmlname"><tr valign="top" class="odd"><td class="tblQmlPropNode"><p><a name="sourceSize-prop"></a><span class="name">sourceSize</span> : <span class="type"><a href="qsize.html">QSize</a></span></p></td></tr></table></div><div class="qmldoc"><p>This property holds the actual width and height of the loaded image.</p>
<p>In <a href="qml-borderimage.html">BorderImage</a>, this property is read-only.</p>
<p><b>See also </b><a href="qml-image.html#sourceSize-prop">Image::sourceSize</a>.</p>
</div></div><!-- @@@sourceSize -->
<br/>
<!-- $$$status -->
<div class="qmlitem"><div class="qmlproto"><table class="qmlname"><tr valign="top" class="odd"><td class="tblQmlPropNode"><p><a name="status-prop"></a><span class="qmlreadonly">read-only</span><span class="name">status</span> : <span class="type"><a href="qml-enumeration.html">enumeration</a></span></p></td></tr></table></div><div class="qmldoc"><p>This property describes the status of image loading. It can be one of:</p>
<ul>
<li><a href="qml-borderimage.html">BorderImage</a>.Null - no image has been set</li>
<li><a href="qml-borderimage.html">BorderImage</a>.Ready - the image has been loaded</li>
<li><a href="qml-borderimage.html">BorderImage</a>.Loading - the image is currently being loaded</li>
<li><a href="qml-borderimage.html">BorderImage</a>.Error - an error occurred while loading the image</li>
</ul>
<p><b>See also </b><a href="qml-borderimage.html#progress-prop">progress</a>.</p>
</div></div><!-- @@@status -->
<br/>
<p class="naviNextPrevious footerNavi">
</p>
<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>
|