/usr/share/qt5/doc/qtquick/qml-qtquick-image.html is in qtdeclarative5-doc-html 5.9.5-0ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 | <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- qquickimage.cpp -->
<title>Image QML Type | Qt Quick 5.9</title>
<link rel="stylesheet" type="text/css" href="style/offline-simple.css" />
<script type="text/javascript">
document.getElementsByTagName("link").item(0).setAttribute("href", "style/offline.css");
// loading style sheet breaks anchors that were jumped to before
// so force jumping to anchor again
setTimeout(function() {
var anchor = location.hash;
// need to jump to different anchor first (e.g. none)
location.hash = "#";
setTimeout(function() {
location.hash = anchor;
}, 0);
}, 0);
</script>
</head>
<body>
<div class="header" id="qtdocheader">
<div class="main">
<div class="main-rounded">
<div class="navigationbar">
<table><tr>
<td >Qt 5.9</td><td ><a href="qtquick-index.html">Qt Quick</a></td><td ><a href="qtquick-qmlmodule.html">QML Types</a></td><td >Image QML Type</td></tr></table><table class="buildversion"><tr>
<td id="buildversion" width="100%" align="right">Qt 5.9.5 Reference Documentation</td>
</tr></table>
</div>
</div>
<div class="content">
<div class="line">
<div class="content mainContent">
<div class="sidebar">
<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">Performance</a></li>
</ul>
</div>
<div class="sidebar-content" id="sidebar-content"></div></div>
<h1 class="title">Image QML Type</h1>
<span class="subtitle"></span>
<!-- $$$Image-brief -->
<p>Displays an image <a href="#details">More...</a></p>
<!-- @@@Image -->
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> Import Statement:</td><td class="memItemRight bottomAlign"> import QtQuick 2.7</td></tr><tr><td class="memItemLeft rightAlign topAlign"> Inherits:</td><td class="memItemRight bottomAlign"> <p><a href="qml-qtquick-item.html">Item</a></p>
</td></tr><tr><td class="memItemLeft rightAlign topAlign"> Inherited By:</td><td class="memItemRight bottomAlign"> <p><a href="qml-qtquick-animatedimage.html">AnimatedImage</a></p>
</td></tr></table></div><ul>
<li><a href="qml-qtquick-image-members.html">List of all members, including inherited members</a></li>
</ul>
<a name="properties"></a>
<h2 id="properties">Properties</h2>
<ul>
<li class="fn"><b><b><a href="qml-qtquick-image.html#asynchronous-prop">asynchronous</a></b></b> : bool</li>
<li class="fn"><b><b><a href="qml-qtquick-image.html#autoTransform-prop">autoTransform</a></b></b> : bool</li>
<li class="fn"><b><b><a href="qml-qtquick-image.html#cache-prop">cache</a></b></b> : bool</li>
<li class="fn"><b><b><a href="qml-qtquick-image.html#fillMode-prop">fillMode</a></b></b> : enumeration</li>
<li class="fn"><b><b><a href="qml-qtquick-image.html#horizontalAlignment-prop">horizontalAlignment</a></b></b> : enumeration</li>
<li class="fn"><b><b><a href="qml-qtquick-image.html#mipmap-prop">mipmap</a></b></b> : bool</li>
<li class="fn"><b><b><a href="qml-qtquick-image.html#mirror-prop">mirror</a></b></b> : bool</li>
<li class="fn"><b><b><a href="qml-qtquick-image.html#paintedHeight-prop">paintedHeight</a></b></b> : real</li>
<li class="fn"><b><b><a href="qml-qtquick-image.html#paintedWidth-prop">paintedWidth</a></b></b> : real</li>
<li class="fn"><b><b><a href="qml-qtquick-image.html#progress-prop">progress</a></b></b> : real</li>
<li class="fn"><b><b><a href="qml-qtquick-image.html#smooth-prop">smooth</a></b></b> : bool</li>
<li class="fn"><b><b><a href="qml-qtquick-image.html#source-prop">source</a></b></b> : url</li>
<li class="fn"><b><b><a href="qml-qtquick-image.html#sourceSize-prop">sourceSize</a></b></b> : QSize</li>
<li class="fn"><b><b><a href="qml-qtquick-image.html#status-prop">status</a></b></b> : enumeration</li>
<li class="fn"><b><b><a href="qml-qtquick-image.html#verticalAlignment-prop">verticalAlignment</a></b></b> : enumeration</li>
</ul>
<!-- $$$Image-description -->
<a name="details"></a>
<h2 id="details">Detailed Description</h2>
<p>The Image type displays an image.</p>
<p>The source of the image is specified as a URL using the <a href="qml-qtquick-image.html#source-prop">source</a> property. Images can be supplied in any of the standard image formats supported by Qt, including bitmap formats such as PNG and JPEG, and vector graphics formats such as SVG. If you need to display animated images, use <a href="qtquick-imageelements-example.html#animatedsprite">AnimatedSprite</a> or <a href="qml-qtquick-animatedimage.html">AnimatedImage</a>.</p>
<p>If the <a href="qml-qtquick-item.html#width-prop">width</a> and <a href="qml-qtquick-item.html#height-prop">height</a> properties are not specified, the Image automatically uses the size of the loaded image. By default, specifying the width and height of the item causes the image to be scaled to that size. This behavior can be changed by setting the <a href="qml-qtquick-image.html#fillMode-prop">fillMode</a> property, allowing the image to be stretched and tiled instead.</p>
<a name="example-usage"></a>
<h2 id="example-usage">Example Usage</h2>
<p>The following example shows the simplest usage of the Image type.</p>
<pre class="qml">
import QtQuick 2.0
<span class="type"><a href="qml-qtquick-image.html">Image</a></span> {
<span class="name">source</span>: <span class="string">"pics/qtlogo.png"</span>
}
</pre>
<div style="float: left; margin-right: 2em"><p class="centerAlign"><img src="images/declarative-qtlogo.png" alt="" /></p></div><br style="clear: both" /><a name="performance"></a>
<h2 id="performance">Performance</h2>
<p>By default, locally available images are loaded immediately, and the user interface is blocked until loading is complete. If a large image is to be loaded, it may be preferable to load the image in a low priority thread, by enabling the <a href="qml-qtquick-image.html#asynchronous-prop">asynchronous</a> property.</p>
<p>If the image is obtained from a network rather than a local resource, it is automatically loaded asynchronously, and the <a href="qml-qtquick-image.html#progress-prop">progress</a> and <a href="qml-qtquick-image.html#status-prop">status</a> properties are updated as appropriate.</p>
<p>Images are cached and shared internally, so if several Image items have the same <a href="qml-qtquick-image.html#source-prop">source</a>, only one copy of the image will be loaded.</p>
<p><b>Note</b>: Images are often the greatest user of memory in QML user interfaces. It is recommended that images which do not form part of the user interface have their size bounded via the <a href="qml-qtquick-image.html#sourceSize-prop">sourceSize</a> property. This is especially important for content that is loaded from external sources or provided by the user.</p>
<p><b>See also </b><a href="qtquick-imageelements-example.html">Qt Quick Examples - Image Elements</a> and <a href="qquickimageprovider.html">QQuickImageProvider</a>.</p>
<!-- @@@Image -->
<h2>Property Documentation</h2>
<!-- $$$asynchronous -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="asynchronous-prop">
<td class="tblQmlPropNode"><p>
<a name="asynchronous-prop"></a><span class="name">asynchronous</span> : <span class="type">bool</span></p></td></tr>
</table></div>
</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 asynchronously.</p>
</div></div><!-- @@@asynchronous -->
<br/>
<!-- $$$autoTransform -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="autoTransform-prop">
<td class="tblQmlPropNode"><p>
<a name="autoTransform-prop"></a><span class="name">autoTransform</span> : <span class="type">bool</span></p></td></tr>
</table></div>
</div><div class="qmldoc"><p>This property holds whether the image should automatically apply image transformation metadata such as EXIF orientation.</p>
<p>By default, this property is set to false.</p>
<p>This QML property was introduced in Qt 5.5.</p>
</div></div><!-- @@@autoTransform -->
<br/>
<!-- $$$cache -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="cache-prop">
<td class="tblQmlPropNode"><p>
<a name="cache-prop"></a><span class="name">cache</span> : <span class="type">bool</span></p></td></tr>
</table></div>
</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>
</div></div><!-- @@@cache -->
<br/>
<!-- $$$fillMode -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="fillMode-prop">
<td class="tblQmlPropNode"><p>
<a name="fillMode-prop"></a><span class="name">fillMode</span> : <span class="type">enumeration</span></p></td></tr>
</table></div>
</div><div class="qmldoc"><p>Set this property to define what happens when the source image has a different size than the item.</p>
<ul>
<li>Image.Stretch - the image is scaled to fit</li>
<li>Image.PreserveAspectFit - the image is scaled uniformly to fit without cropping</li>
<li>Image.PreserveAspectCrop - the image is scaled uniformly to fill, cropping if necessary</li>
<li>Image.Tile - the image is duplicated horizontally and vertically</li>
<li>Image.TileVertically - the image is stretched horizontally and tiled vertically</li>
<li>Image.TileHorizontally - the image is stretched vertically and tiled horizontally</li>
<li>Image.Pad - the image is not transformed</li>
</ul>
<div class="table"><table class="generic">
<tr valign="top" class="odd"><td ><p class="centerAlign"><img src="images/declarative-qtlogo-stretch.png" alt="" /></p></td><td >Stretch (default)<pre class="qml">
<span class="type"><a href="qml-qtquick-image.html">Image</a></span> {
<span class="name">width</span>: <span class="number">130</span>; <span class="name">height</span>: <span class="number">100</span>
<span class="name">source</span>: <span class="string">"qtlogo.png"</span>
}
</pre>
</td></tr>
<tr valign="top" class="even"><td ><p class="centerAlign"><img src="images/declarative-qtlogo-preserveaspectfit.png" alt="" /></p></td><td >PreserveAspectFit<pre class="qml">
<span class="type"><a href="qml-qtquick-image.html">Image</a></span> {
<span class="name">width</span>: <span class="number">130</span>; <span class="name">height</span>: <span class="number">100</span>
<span class="name">fillMode</span>: <span class="name">Image</span>.<span class="name">PreserveAspectFit</span>
<span class="name">source</span>: <span class="string">"qtlogo.png"</span>
}
</pre>
</td></tr>
<tr valign="top" class="odd"><td ><p class="centerAlign"><img src="images/declarative-qtlogo-preserveaspectcrop.png" alt="" /></p></td><td >PreserveAspectCrop<pre class="qml">
<span class="type"><a href="qml-qtquick-image.html">Image</a></span> {
<span class="name">width</span>: <span class="number">130</span>; <span class="name">height</span>: <span class="number">100</span>
<span class="name">fillMode</span>: <span class="name">Image</span>.<span class="name">PreserveAspectCrop</span>
<span class="name">source</span>: <span class="string">"qtlogo.png"</span>
<span class="name">clip</span>: <span class="number">true</span>
}
</pre>
</td></tr>
<tr valign="top" class="even"><td ><p class="centerAlign"><img src="images/declarative-qtlogo-tile.png" alt="" /></p></td><td >Tile<pre class="qml">
<span class="type"><a href="qml-qtquick-image.html">Image</a></span> {
<span class="name">width</span>: <span class="number">120</span>; <span class="name">height</span>: <span class="number">120</span>
<span class="name">fillMode</span>: <span class="name">Image</span>.<span class="name">Tile</span>
<span class="name">horizontalAlignment</span>: <span class="name">Image</span>.<span class="name">AlignLeft</span>
<span class="name">verticalAlignment</span>: <span class="name">Image</span>.<span class="name">AlignTop</span>
<span class="name">source</span>: <span class="string">"qtlogo.png"</span>
}
</pre>
</td></tr>
<tr valign="top" class="odd"><td ><p class="centerAlign"><img src="images/declarative-qtlogo-tilevertically.png" alt="" /></p></td><td >TileVertically<pre class="qml">
<span class="type"><a href="qml-qtquick-image.html">Image</a></span> {
<span class="name">width</span>: <span class="number">120</span>; <span class="name">height</span>: <span class="number">120</span>
<span class="name">fillMode</span>: <span class="name">Image</span>.<span class="name">TileVertically</span>
<span class="name">verticalAlignment</span>: <span class="name">Image</span>.<span class="name">AlignTop</span>
<span class="name">source</span>: <span class="string">"qtlogo.png"</span>
}
</pre>
</td></tr>
<tr valign="top" class="even"><td ><p class="centerAlign"><img src="images/declarative-qtlogo-tilehorizontally.png" alt="" /></p></td><td >TileHorizontally<pre class="qml">
<span class="type"><a href="qml-qtquick-image.html">Image</a></span> {
<span class="name">width</span>: <span class="number">120</span>; <span class="name">height</span>: <span class="number">120</span>
<span class="name">fillMode</span>: <span class="name">Image</span>.<span class="name">TileHorizontally</span>
<span class="name">verticalAlignment</span>: <span class="name">Image</span>.<span class="name">AlignLeft</span>
<span class="name">source</span>: <span class="string">"qtlogo.png"</span>
}
</pre>
</td></tr>
</table></div>
<p>Note that <code>clip</code> is <code>false</code> by default which means that the item might paint outside its bounding rectangle even if the fillMode is set to <code>PreserveAspectCrop</code>.</p>
<p><b>See also </b><a href="qtquick-imageelements-example.html">Qt Quick Examples - Image Elements</a>.</p>
</div></div><!-- @@@fillMode -->
<br/>
<!-- $$$horizontalAlignment -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="horizontalAlignment-prop">
<td class="tblQmlPropNode"><p>
<a name="horizontalAlignment-prop"></a><span class="name">horizontalAlignment</span> : <span class="type">enumeration</span></p></td></tr>
</table></div>
</div><div class="qmldoc"><p>Sets the horizontal and vertical alignment of the image. By default, the image is center aligned.</p>
<p>The valid values for <code>horizontalAlignment</code> are <code>Image.AlignLeft</code>, <code>Image.AlignRight</code> and <code>Image.AlignHCenter</code>. The valid values for <code>verticalAlignment</code> are <code>Image.AlignTop</code>, <code>Image.AlignBottom</code> and <code>Image.AlignVCenter</code>.</p>
</div></div><!-- @@@horizontalAlignment -->
<br/>
<!-- $$$mipmap -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="mipmap-prop">
<td class="tblQmlPropNode"><p>
<a name="mipmap-prop"></a><span class="name">mipmap</span> : <span class="type">bool</span></p></td></tr>
</table></div>
</div><div class="qmldoc"><p>This property holds whether the image uses mipmap filtering when scaled or transformed.</p>
<p>Mipmap filtering gives better visual quality when scaling down compared to smooth, but it may come at a performance cost (both when initializing the image and during rendering).</p>
<p>By default, this property is set to false.</p>
<p>This QML property was introduced in Qt 5.3.</p>
<p><b>See also </b><a href="qml-qtquick-image.html#smooth-prop">smooth</a>.</p>
</div></div><!-- @@@mipmap -->
<br/>
<!-- $$$mirror -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="mirror-prop">
<td class="tblQmlPropNode"><p>
<a name="mirror-prop"></a><span class="name">mirror</span> : <span class="type">bool</span></p></td></tr>
</table></div>
</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>
</div></div><!-- @@@mirror -->
<br/>
<!-- $$$paintedHeight -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="paintedHeight-prop">
<td class="tblQmlPropNode"><p>
<a name="paintedHeight-prop"></a><span class="name">paintedHeight</span> : <span class="type">real</span></p></td></tr>
</table></div>
</div><div class="qmldoc"><p>These properties hold the size of the image that is actually painted. In most cases it is the same as <code>width</code> and <code>height</code>, but when using an <a href="qml-qtquick-image.html#fillMode-prop">Image.PreserveAspectFit</a> or an <a href="qml-qtquick-image.html#fillMode-prop">Image.PreserveAspectCrop</a> <code>paintedWidth</code> or <code>paintedHeight</code> can be smaller or larger than <code>width</code> and <code>height</code> of the Image item.</p>
</div></div><!-- @@@paintedHeight -->
<br/>
<!-- $$$paintedWidth -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="paintedWidth-prop">
<td class="tblQmlPropNode"><p>
<a name="paintedWidth-prop"></a><span class="name">paintedWidth</span> : <span class="type">real</span></p></td></tr>
</table></div>
</div><div class="qmldoc"><p>These properties hold the size of the image that is actually painted. In most cases it is the same as <code>width</code> and <code>height</code>, but when using an <a href="qml-qtquick-image.html#fillMode-prop">Image.PreserveAspectFit</a> or an <a href="qml-qtquick-image.html#fillMode-prop">Image.PreserveAspectCrop</a> <code>paintedWidth</code> or <code>paintedHeight</code> can be smaller or larger than <code>width</code> and <code>height</code> of the Image item.</p>
</div></div><!-- @@@paintedWidth -->
<br/>
<!-- $$$progress -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="progress-prop">
<td class="tblQmlPropNode"><p>
<a name="progress-prop"></a><span class="name">progress</span> : <span class="type">real</span></p></td></tr>
</table></div>
</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-qtquick-image.html#status-prop">status</a>.</p>
</div></div><!-- @@@progress -->
<br/>
<!-- $$$smooth -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="smooth-prop">
<td class="tblQmlPropNode"><p>
<a name="smooth-prop"></a><span class="name">smooth</span> : <span class="type">bool</span></p></td></tr>
</table></div>
</div><div class="qmldoc"><p>This property holds whether the image is smoothly filtered when scaled or transformed. Smooth filtering gives better visual quality, but it may be slower on some hardware. 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 true.</p>
<p><b>See also </b><a href="qml-qtquick-image.html#mipmap-prop">mipmap</a>.</p>
</div></div><!-- @@@smooth -->
<br/>
<!-- $$$source -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="source-prop">
<td class="tblQmlPropNode"><p>
<a name="source-prop"></a><span class="name">source</span> : <span class="type">url</span></p></td></tr>
</table></div>
</div><div class="qmldoc"><p>Image can handle any image format supported by Qt, loaded from any URL scheme supported by Qt.</p>
<p>The URL may be absolute, or relative to the URL of the component.</p>
<p><b>See also </b><a href="qquickimageprovider.html">QQuickImageProvider</a>.</p>
</div></div><!-- @@@source -->
<br/>
<!-- $$$sourceSize -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="sourceSize-prop">
<td class="tblQmlPropNode"><p>
<a name="sourceSize-prop"></a><span class="name">sourceSize</span> : <span class="type">QSize</span></p></td></tr>
</table></div>
</div><div class="qmldoc"><p>This property holds the actual width and height of the loaded image.</p>
<p>Unlike the <a href="qml-qtquick-item.html#width-prop">width</a> and <a href="qml-qtquick-item.html#height-prop">height</a> properties, which scale the painting of the image, this property sets the actual number of pixels stored for the loaded image so that large images do not use more memory than necessary. For example, this ensures the image in memory is no larger than 1024x1024 pixels, regardless of the Image's <a href="qml-qtquick-item.html#width-prop">width</a> and <a href="qml-qtquick-item.html#height-prop">height</a> values:</p>
<pre class="cpp">
Rectangle {
width: <span class="operator">.</span><span class="operator">.</span><span class="operator">.</span>
height: <span class="operator">.</span><span class="operator">.</span><span class="operator">.</span>
Image {
anchors<span class="operator">.</span>fill: parent
source: <span class="string">"reallyBigImage.jpg"</span>
sourceSize<span class="operator">.</span>width: <span class="number">1024</span>
sourceSize<span class="operator">.</span>height: <span class="number">1024</span>
}
}
</pre>
<p>If the image's actual size is larger than the sourceSize, the image is scaled down. If only one dimension of the size is set to greater than 0, the other dimension is set in proportion to preserve the source image's aspect ratio. (The <a href="qml-qtquick-image.html#fillMode-prop">fillMode</a> is independent of this.)</p>
<p>If both the sourceSize.width and sourceSize.height are set the image will be scaled down to fit within the specified size (unless PreserveAspectCrop or PreserveAspectFit are used, then it will be scaled to match the optimal size for cropping/fitting), maintaining the image's aspect ratio. The actual size of the image after scaling is available via <a href="qml-qtquick-item.html#implicitWidth-prop">Item::implicitWidth</a> and <a href="qml-qtquick-item.html#implicitHeight-prop">Item::implicitHeight</a>.</p>
<p>If the source is an intrinsically scalable image (eg. SVG), this property determines the size of the loaded image regardless of intrinsic size. Avoid changing this property dynamically; rendering an SVG is <i>slow</i> compared to an image.</p>
<p>If the source is a non-scalable image (eg. JPEG), the loaded image will be no greater than this property specifies. For some formats (currently only JPEG), the whole image will never actually be loaded into memory.</p>
<p>sourceSize can be cleared to the natural size of the image by setting sourceSize to <code>undefined</code>.</p>
<p><b>Note: </b><i>Changing this property dynamically causes the image source to be reloaded, potentially even from the network, if it is not in the disk cache.</i></p></div></div><!-- @@@sourceSize -->
<br/>
<!-- $$$status -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="status-prop">
<td class="tblQmlPropNode"><p>
<a name="status-prop"></a><span class="name">status</span> : <span class="type">enumeration</span></p></td></tr>
</table></div>
</div><div class="qmldoc"><p>This property holds the status of image loading. It can be one of:</p>
<ul>
<li>Image.Null - no image has been set</li>
<li>Image.Ready - the image has been loaded</li>
<li>Image.Loading - the image is currently being loaded</li>
<li>Image.Error - an error occurred while loading the image</li>
</ul>
<p>Use this status to provide an update or respond to the status change in some way. For example, you could:</p>
<ul>
<li>Trigger a state change:<pre class="qml">
<span class="type"><a href="qml-qtquick-state.html">State</a></span> { <span class="name">name</span>: <span class="string">'loaded'</span>; <span class="name">when</span>: <span class="name">image</span>.<span class="name">status</span> <span class="operator">==</span> <span class="name">Image</span>.<span class="name">Ready</span> }
</pre>
</li>
<li>Implement an <code>onStatusChanged</code> signal handler:<pre class="qml">
<span class="type"><a href="qml-qtquick-image.html">Image</a></span> {
<span class="name">id</span>: <span class="name">image</span>
<span class="name">onStatusChanged</span>: <span class="keyword">if</span> (<span class="name">image</span>.<span class="name">status</span> <span class="operator">==</span> <span class="name">Image</span>.<span class="name">Ready</span>) <span class="name">console</span>.<span class="name">log</span>(<span class="string">'Loaded'</span>)
}
</pre>
</li>
<li>Bind to the status value:<pre class="qml">
<span class="type"><a href="qml-qtquick-text.html">Text</a></span> { <span class="name">text</span>: <span class="name">image</span>.<span class="name">status</span> <span class="operator">==</span> <span class="name">Image</span>.<span class="name">Ready</span> ? <span class="string">'Loaded'</span> : <span class="string">'Not loaded'</span> }
</pre>
</li>
</ul>
<p><b>See also </b><a href="qml-qtquick-image.html#progress-prop">progress</a>.</p>
</div></div><!-- @@@status -->
<br/>
<!-- $$$verticalAlignment -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="verticalAlignment-prop">
<td class="tblQmlPropNode"><p>
<a name="verticalAlignment-prop"></a><span class="name">verticalAlignment</span> : <span class="type">enumeration</span></p></td></tr>
</table></div>
</div><div class="qmldoc"><p>Sets the horizontal and vertical alignment of the image. By default, the image is center aligned.</p>
<p>The valid values for <code>horizontalAlignment</code> are <code>Image.AlignLeft</code>, <code>Image.AlignRight</code> and <code>Image.AlignHCenter</code>. The valid values for <code>verticalAlignment</code> are <code>Image.AlignTop</code>, <code>Image.AlignBottom</code> and <code>Image.AlignVCenter</code>.</p>
</div></div><!-- @@@verticalAlignment -->
<br/>
</div>
</div>
</div>
</div>
</div>
<div class="footer">
<p>
<acronym title="Copyright">©</acronym> 2017 The Qt Company Ltd.
Documentation contributions included herein are the copyrights of
their respective owners.<br> 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.<br> Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property
of their respective owners. </p>
</div>
</body>
</html>
|