This file is indexed.

/usr/share/qt5/doc/qtquick/qml-qtquick-loader.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
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- qquickloader.cpp -->
  <title>Loader 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 >Loader 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="#signals">Signals</a></li>
<li class="level1"><a href="#methods">Methods</a></li>
<li class="level1"><a href="#details">Detailed Description</a></li>
<li class="level2"><a href="#loader-sizing-behavior">Loader Sizing Behavior</a></li>
<li class="level2"><a href="#receiving-signals-from-loaded-objects">Receiving Signals from Loaded Objects</a></li>
<li class="level2"><a href="#focus-and-key-events">Focus and Key Events</a></li>
<li class="level2"><a href="#using-a-loader-within-a-view-delegate">Using a Loader within a View Delegate</a></li>
</ul>
</div>
<div class="sidebar-content" id="sidebar-content"></div></div>
<h1 class="title">Loader QML Type</h1>
<span class="subtitle"></span>
<!-- $$$Loader-brief -->
<p>Allows dynamic loading of a subtree from a URL or Component <a href="#details">More...</a></p>
<!-- @@@Loader -->
<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></table></div><ul>
<li><a href="qml-qtquick-loader-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-loader.html#active-prop">active</a></b></b> : bool</li>
<li class="fn"><b><b><a href="qml-qtquick-loader.html#asynchronous-prop">asynchronous</a></b></b> : bool</li>
<li class="fn"><b><b><a href="qml-qtquick-loader.html#item-prop">item</a></b></b> : object</li>
<li class="fn"><b><b><a href="qml-qtquick-loader.html#progress-prop">progress</a></b></b> : real</li>
<li class="fn"><b><b><a href="qml-qtquick-loader.html#source-prop">source</a></b></b> : url</li>
<li class="fn"><b><b><a href="qml-qtquick-loader.html#sourceComponent-prop">sourceComponent</a></b></b> : Component</li>
<li class="fn"><b><b><a href="qml-qtquick-loader.html#status-prop">status</a></b></b> : enumeration</li>
</ul>
<a name="signals"></a>
<h2 id="signals">Signals</h2>
<ul>
<li class="fn"><b><b><a href="qml-qtquick-loader.html#loaded-signal">loaded</a></b></b>()</li>
</ul>
<a name="methods"></a>
<h2 id="methods">Methods</h2>
<ul>
<li class="fn">object <b><b><a href="qml-qtquick-loader.html#setSource-method">setSource</a></b></b>(url <i>source</i>, object <i>properties</i>)</li>
</ul>
<!-- $$$Loader-description -->
<a name="details"></a>
<h2 id="details">Detailed Description</h2>
<p>Loader is used to dynamically load QML components.</p>
<p>Loader can load a QML file (using the <a href="qml-qtquick-loader.html#source-prop">source</a> property) or a Component object (using the <a href="qml-qtquick-loader.html#sourceComponent-prop">sourceComponent</a> property). It is useful for delaying the creation of a component until it is required: for example, when a component should be created on demand, or when a component should not be created unnecessarily for performance reasons.</p>
<p>Here is a Loader that loads &quot;Page1.qml&quot; as a component when the <a href="qml-qtquick-mousearea.html">MouseArea</a> is clicked:</p>
<pre class="qml">

  import QtQuick 2.0

  <span class="type"><a href="qml-qtquick-item.html">Item</a></span> {
      <span class="name">width</span>: <span class="number">200</span>; <span class="name">height</span>: <span class="number">200</span>

      <span class="type"><a href="qml-qtquick-loader.html">Loader</a></span> { <span class="name">id</span>: <span class="name">pageLoader</span> }

      <span class="type"><a href="qml-qtquick-mousearea.html">MouseArea</a></span> {
          <span class="name">anchors</span>.fill: <span class="name">parent</span>
          <span class="name">onClicked</span>: <span class="name">pageLoader</span>.<span class="name">source</span> <span class="operator">=</span> <span class="string">&quot;Page1.qml&quot;</span>
      }
  }

</pre>
<p>The loaded object can be accessed using the <a href="qml-qtquick-loader.html#item-prop">item</a> property.</p>
<p>If the <a href="qml-qtquick-loader.html#source-prop">source</a> or <a href="qml-qtquick-loader.html#sourceComponent-prop">sourceComponent</a> changes, any previously instantiated items are destroyed. Setting <a href="qml-qtquick-loader.html#source-prop">source</a> to an empty string or setting <a href="qml-qtquick-loader.html#sourceComponent-prop">sourceComponent</a> to <code>undefined</code> destroys the currently loaded object, freeing resources and leaving the Loader empty.</p>
<a name="loader-sizing-behavior"></a>
<h3 >Loader Sizing Behavior</h3>
<p>If the source component is not an Item type, Loader does not apply any special sizing rules. When used to load visual types, Loader applies the following sizing rules:</p>
<ul>
<li>If an explicit size is not specified for the Loader, the Loader is automatically resized to the size of the loaded item once the component is loaded.</li>
<li>If the size of the Loader is specified explicitly by setting the width, height or by anchoring, the loaded item will be resized to the size of the Loader.</li>
</ul>
<p>In both scenarios the size of the item and the Loader are identical. This ensures that anchoring to the Loader is equivalent to anchoring to the loaded item.</p>
<div class="table"><table class="generic">
 <tr valign="top" class="odd"><td >sizeloader.qml</td><td >sizeitem.qml</td></tr>
<tr valign="top" class="even"><td ><pre class="qml">

  import QtQuick 2.0

  <span class="type"><a href="qml-qtquick-item.html">Item</a></span> {
    <span class="name">width</span>: <span class="number">200</span>; <span class="name">height</span>: <span class="number">200</span>

    <span class="type"><a href="qml-qtquick-loader.html">Loader</a></span> {
      <span class="comment">// Explicitly set the size of the</span>
      <span class="comment">// Loader to the parent item's size</span>
      <span class="name">anchors</span>.fill: <span class="name">parent</span>
      <span class="name">sourceComponent</span>: <span class="name">rect</span>
    }

    <span class="type">Component</span> {
      <span class="name">id</span>: <span class="name">rect</span>
      <span class="type"><a href="qml-qtquick-rectangle.html">Rectangle</a></span> {
        <span class="name">width</span>: <span class="number">50</span>
        <span class="name">height</span>: <span class="number">50</span>
        <span class="name">color</span>: <span class="string">&quot;red&quot;</span>
        }
    }
  }

</pre>
</td><td ><pre class="qml">

  import QtQuick 2.0

  <span class="type"><a href="qml-qtquick-item.html">Item</a></span> {
    <span class="name">width</span>: <span class="number">200</span>; <span class="name">height</span>: <span class="number">200</span>

    <span class="type"><a href="qml-qtquick-loader.html">Loader</a></span> {
      <span class="comment">// position the Loader in the center</span>
      <span class="comment">// of the parent</span>
      <span class="name">anchors</span>.centerIn: <span class="name">parent</span>
      <span class="name">sourceComponent</span>: <span class="name">rect</span>
    }

    <span class="type">Component</span> {
        <span class="name">id</span>: <span class="name">rect</span>
        <span class="type"><a href="qml-qtquick-rectangle.html">Rectangle</a></span> {
            <span class="name">width</span>: <span class="number">50</span>
            <span class="name">height</span>: <span class="number">50</span>
            <span class="name">color</span>: <span class="string">&quot;red&quot;</span>
        }
    }
  }

</pre>
</td></tr>
<tr valign="top" class="odd"><td >The red rectangle will be sized to the size of the root item.</td><td >The red rectangle will be 50x50, centered in the root item.</td></tr>
</table></div>
<a name="receiving-signals-from-loaded-objects"></a>
<h3 >Receiving Signals from Loaded Objects</h3>
<p>Any signals emitted from the loaded object can be received using the Connections type. For example, the following <code>application.qml</code> loads <code>MyItem.qml</code>, and is able to receive the <code>message</code> signal from the loaded item through a Connections object:</p>
<div class="table"><table class="generic" width="70%">
 <tr valign="top" class="odd"><td >application.qml</td><td >MyItem.qml</td></tr>
<tr valign="top" class="even"><td ><pre class="qml">

  import QtQuick 2.0

  <span class="type"><a href="qml-qtquick-item.html">Item</a></span> {
      <span class="name">width</span>: <span class="number">100</span>; <span class="name">height</span>: <span class="number">100</span>

      <span class="type"><a href="qml-qtquick-loader.html">Loader</a></span> {
         <span class="name">id</span>: <span class="name">myLoader</span>
         <span class="name">source</span>: <span class="string">&quot;MyItem.qml&quot;</span>
      }

      <span class="type">Connections</span> {
          <span class="name">target</span>: <span class="name">myLoader</span>.<span class="name">item</span>
          <span class="name">onMessage</span>: <span class="name">console</span>.<span class="name">log</span>(<span class="name">msg</span>)
      }
  }

</pre>
</td><td ><pre class="qml">

  import QtQuick 2.0

  <span class="type"><a href="qml-qtquick-rectangle.html">Rectangle</a></span> {
     <span class="name">id</span>: <span class="name">myItem</span>
     signal <span class="type">message</span>(string msg)

     <span class="name">width</span>: <span class="number">100</span>; <span class="name">height</span>: <span class="number">100</span>

     <span class="type"><a href="qml-qtquick-mousearea.html">MouseArea</a></span> {
         <span class="name">anchors</span>.fill: <span class="name">parent</span>
         <span class="name">onClicked</span>: <span class="name">myItem</span>.<span class="name">message</span>(<span class="string">&quot;clicked!&quot;</span>)
     }
  }

</pre>
</td></tr>
</table></div>
<p>Alternatively, since <code>MyItem.qml</code> is loaded within the scope of the Loader, it could also directly call any function defined in the Loader or its parent <a href="qml-qtquick-item.html">Item</a>.</p>
<a name="focus-and-key-events"></a>
<h3 >Focus and Key Events</h3>
<p>Loader is a focus scope. Its <a href="qml-qtquick-item.html#focus-prop">focus</a> property must be set to <code>true</code> for any of its children to get the <i>active focus</i>. (See <a href="qtquick-input-focus.html">Keyboard Focus in Qt Quick</a> for more details.) Any key events received in the loaded item should likely also be <a href="qml-qtquick-keyevent.html#accepted-prop">accepted</a> so they are not propagated to the Loader.</p>
<p>For example, the following <code>application.qml</code> loads <code>KeyReader.qml</code> when the <a href="qml-qtquick-mousearea.html">MouseArea</a> is clicked. Notice the <a href="qml-qtquick-item.html#focus-prop">focus</a> property is set to <code>true</code> for the Loader as well as the <a href="qml-qtquick-item.html">Item</a> in the dynamically loaded object:</p>
<div class="table"><table class="generic">
 <tr valign="top" class="odd"><td >application.qml</td><td >KeyReader.qml</td></tr>
<tr valign="top" class="even"><td ><pre class="qml">

  import QtQuick 2.0

  <span class="type"><a href="qml-qtquick-rectangle.html">Rectangle</a></span> {
      <span class="name">width</span>: <span class="number">200</span>; <span class="name">height</span>: <span class="number">200</span>

      <span class="type"><a href="qml-qtquick-loader.html">Loader</a></span> {
          <span class="name">id</span>: <span class="name">loader</span>
          <span class="name">focus</span>: <span class="number">true</span>
      }

      <span class="type"><a href="qml-qtquick-mousearea.html">MouseArea</a></span> {
          <span class="name">anchors</span>.fill: <span class="name">parent</span>
          <span class="name">onClicked</span>: {
              <span class="name">loader</span>.<span class="name">source</span> <span class="operator">=</span> <span class="string">&quot;KeyReader.qml&quot;</span>
          }
      }

      <span class="name">Keys</span>.onPressed: {
          <span class="name">console</span>.<span class="name">log</span>(<span class="string">&quot;Captured:&quot;</span>,
                      <span class="name">event</span>.<span class="name">text</span>);
      }
  }

</pre>
</td><td ><pre class="qml">

  import QtQuick 2.0

  <span class="type"><a href="qml-qtquick-item.html">Item</a></span> {
      <span class="type"><a href="qml-qtquick-item.html">Item</a></span> {
          <span class="name">focus</span>: <span class="number">true</span>
          <span class="name">Keys</span>.onPressed: {
              <span class="name">console</span>.<span class="name">log</span>(<span class="string">&quot;KeyReader captured:&quot;</span>,
                          <span class="name">event</span>.<span class="name">text</span>);
              <span class="name">event</span>.<span class="name">accepted</span> <span class="operator">=</span> <span class="number">true</span>;
          }
      }
  }

</pre>
</td></tr>
</table></div>
<p>Once <code>KeyReader.qml</code> is loaded, it accepts key events and sets <code>event.accepted</code> to <code>true</code> so that the event is not propagated to the parent <a href="qml-qtquick-rectangle.html">Rectangle</a>.</p>
<p>Since <code>QtQuick 2.0</code>, Loader can also load non-visual components.</p>
<a name="using-a-loader-within-a-view-delegate"></a>
<h3 >Using a Loader within a View Delegate</h3>
<p>In some cases you may wish to use a Loader within a view delegate to improve delegate loading performance. This works well in most cases, but there is one important issue to be aware of related to the creation context of a Component.</p>
<p>In the following example, the <code>index</code> context property inserted by the <a href="qml-qtquick-listview.html">ListView</a> into <code>delegateComponent</code>'s context will be inaccessible to Text, as the Loader will use the creation context of <code>myComponent</code> as the parent context when instantiating it, and <code>index</code> does not refer to anything within that context chain.</p>
<pre class="qml">

  <span class="type"><a href="qml-qtquick-item.html">Item</a></span> {
      <span class="name">width</span>: <span class="number">400</span>
      <span class="name">height</span>: <span class="number">400</span>

      <span class="type">Component</span> {
          <span class="name">id</span>: <span class="name">myComponent</span>
          <span class="type"><a href="qml-qtquick-text.html">Text</a></span> { <span class="name">text</span>: <span class="name">index</span> }    <span class="comment">//fails</span>
      }

      <span class="type"><a href="qml-qtquick-listview.html">ListView</a></span> {
          <span class="name">anchors</span>.fill: <span class="name">parent</span>
          <span class="name">model</span>: <span class="number">5</span>
          <span class="name">delegate</span>: <span class="name">Component</span> {
              <span class="name">id</span>: <span class="name">delegateComponent</span>
              <span class="type"><a href="qml-qtquick-loader.html">Loader</a></span> {
                  <span class="name">sourceComponent</span>: <span class="name">myComponent</span>
              }
          }
      }
  }

</pre>
<p>In this situation we can either move the component inline,</p>
<pre class="qml">

          <span class="name">delegate</span>: <span class="name">Component</span> {
              <span class="type"><a href="qml-qtquick-loader.html">Loader</a></span> {
                  <span class="name">sourceComponent</span>: <span class="name">Component</span> {
                      <span class="type"><a href="qml-qtquick-text.html">Text</a></span> { <span class="name">text</span>: <span class="name">index</span> }    <span class="comment">//okay</span>
                  }
              }
          }

</pre>
<p>into a separate file,</p>
<pre class="qml">

          <span class="name">delegate</span>: <span class="name">Component</span> {
              <span class="type"><a href="qml-qtquick-loader.html">Loader</a></span> {
                  <span class="name">source</span>: <span class="string">&quot;MyComponent.qml&quot;</span> <span class="comment">//okay</span>
              }
          }

</pre>
<p>or explicitly set the required information as a property of the Loader (this works because the Loader sets itself as the context object for the component it is loading).</p>
<pre class="qml">

  <span class="type"><a href="qml-qtquick-item.html">Item</a></span> {
      <span class="name">width</span>: <span class="number">400</span>
      <span class="name">height</span>: <span class="number">400</span>

      <span class="type">Component</span> {
          <span class="name">id</span>: <span class="name">myComponent</span>
          <span class="type"><a href="qml-qtquick-text.html">Text</a></span> { <span class="name">text</span>: <span class="name">modelIndex</span> }    <span class="comment">//okay</span>
      }

      <span class="type"><a href="qml-qtquick-listview.html">ListView</a></span> {
          <span class="name">anchors</span>.fill: <span class="name">parent</span>
          <span class="name">model</span>: <span class="number">5</span>
          <span class="name">delegate</span>: <span class="name">Component</span> {
              <span class="type"><a href="qml-qtquick-loader.html">Loader</a></span> {
                  property <span class="type">int</span> <span class="name">modelIndex</span>: <span class="name">index</span>
                  <span class="name">sourceComponent</span>: <span class="name">myComponent</span>
              }
          }
      }
  }

</pre>
<p><b>See also </b>Dynamic Object Creation.</p>
<!-- @@@Loader -->
<h2>Property Documentation</h2>
<!-- $$$active -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="active-prop">
<td class="tblQmlPropNode"><p>
<a name="active-prop"></a><span class="name">active</span> : <span class="type">bool</span></p></td></tr>
</table></div>
</div><div class="qmldoc"><p>This property is <code>true</code> if the Loader is currently active. The default value for this property is <code>true</code>.</p>
<p>If the Loader is inactive, changing the <a href="qml-qtquick-loader.html#source-prop">source</a> or <a href="qml-qtquick-loader.html#sourceComponent-prop">sourceComponent</a> will not cause the item to be instantiated until the Loader is made active.</p>
<p>Setting the value to inactive will cause any <a href="qml-qtquick-loader.html#item-prop">item</a> loaded by the loader to be released, but will not affect the <a href="qml-qtquick-loader.html#source-prop">source</a> or <a href="qml-qtquick-loader.html#sourceComponent-prop">sourceComponent</a>.</p>
<p>The <a href="qml-qtquick-loader.html#status-prop">status</a> of an inactive loader is always <code>Null</code>.</p>
<p><b>See also </b><a href="qml-qtquick-loader.html#source-prop">source</a> and <a href="qml-qtquick-loader.html#sourceComponent-prop">sourceComponent</a>.</p>
</div></div><!-- @@@active -->
<br/>
<!-- $$$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>This property holds whether the component will be instantiated asynchronously. By default it is <code>false</code>.</p>
<p>When used in conjunction with the <a href="qml-qtquick-loader.html#source-prop">source</a> property, loading and compilation will also be performed in a background thread.</p>
<p>Loading asynchronously creates the objects declared by the component across multiple frames, and reduces the likelihood of glitches in animation. When loading asynchronously the status will change to Loader.Loading. Once the entire component has been created, the <a href="qml-qtquick-loader.html#item-prop">item</a> will be available and the status will change to Loader.Ready.</p>
<p>Changing the value of this property to <code>false</code> while an asynchronous load is in progress will force immediate, synchronous completion. This allows beginning an asynchronous load and then forcing completion if the Loader content must be accessed before the asynchronous load has completed.</p>
<p>To avoid seeing the items loading progressively set <code>visible</code> appropriately, e.g&#x2e;</p>
<pre class="cpp">

  Loader {
      source: <span class="string">&quot;mycomponent.qml&quot;</span>
      asynchronous: <span class="keyword">true</span>
      visible: status <span class="operator">=</span><span class="operator">=</span> Loader<span class="operator">.</span>Ready
  }

</pre>
<p>Note that this property affects object instantiation only; it is unrelated to loading a component asynchronously via a network.</p>
</div></div><!-- @@@asynchronous -->
<br/>
<!-- $$$item -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="item-prop">
<td class="tblQmlPropNode"><p>
<a name="item-prop"></a><span class="name">item</span> : <span class="type">object</span></p></td></tr>
</table></div>
</div><div class="qmldoc"><p>This property holds the top-level object that is currently loaded.</p>
<p>Since <code>QtQuick 2.0</code>, Loader can load any object type.</p>
</div></div><!-- @@@item -->
<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 loading QML data from the network, from 0.0 (nothing loaded) to 1.0 (finished). Most QML files are quite small, so this value will rapidly change from 0 to 1.</p>
<p><b>See also </b><a href="qml-qtquick-loader.html#status-prop">status</a>.</p>
</div></div><!-- @@@progress -->
<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>This property holds the URL of the QML component to instantiate.</p>
<p>Since <code>QtQuick 2.0</code>, Loader is able to load any type of object; it is not restricted to Item types.</p>
<p>To unload the currently loaded object, set this property to an empty string, or set <a href="qml-qtquick-loader.html#sourceComponent-prop">sourceComponent</a> to <code>undefined</code>. Setting <code>source</code> to a new URL will also cause the item created by the previous URL to be unloaded.</p>
<p><b>See also </b><a href="qml-qtquick-loader.html#sourceComponent-prop">sourceComponent</a>, <a href="qml-qtquick-loader.html#status-prop">status</a>, and <a href="qml-qtquick-loader.html#progress-prop">progress</a>.</p>
</div></div><!-- @@@source -->
<br/>
<!-- $$$sourceComponent -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="sourceComponent-prop">
<td class="tblQmlPropNode"><p>
<a name="sourceComponent-prop"></a><span class="name">sourceComponent</span> : <span class="type">Component</span></p></td></tr>
</table></div>
</div><div class="qmldoc"><p>This property holds the Component to instantiate.</p>
<pre class="qml">

  <span class="type"><a href="qml-qtquick-item.html">Item</a></span> {
      <span class="type">Component</span> {
          <span class="name">id</span>: <span class="name">redSquare</span>
          <span class="type"><a href="qml-qtquick-rectangle.html">Rectangle</a></span> { <span class="name">color</span>: <span class="string">&quot;red&quot;</span>; <span class="name">width</span>: <span class="number">10</span>; <span class="name">height</span>: <span class="number">10</span> }
      }

      <span class="type"><a href="qml-qtquick-loader.html">Loader</a></span> { <span class="name">sourceComponent</span>: <span class="name">redSquare</span> }
      <span class="type"><a href="qml-qtquick-loader.html">Loader</a></span> { <span class="name">sourceComponent</span>: <span class="name">redSquare</span>; <span class="name">x</span>: <span class="number">10</span> }
  }

</pre>
<p>To unload the currently loaded object, set this property to <code>undefined</code>.</p>
<p>Since <code>QtQuick 2.0</code>, Loader is able to load any type of object; it is not restricted to Item types.</p>
<p><b>See also </b><a href="qml-qtquick-loader.html#source-prop">source</a> and <a href="qml-qtquick-loader.html#progress-prop">progress</a>.</p>
</div></div><!-- @@@sourceComponent -->
<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 QML loading. It can be one of:</p>
<ul>
<li>Loader.Null - the loader is inactive or no QML source has been set</li>
<li>Loader.Ready - the QML source has been loaded</li>
<li>Loader.Loading - the QML source is currently being loaded</li>
<li>Loader.Error - an error occurred while loading the QML source</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">loader</span>.<span class="name">status</span> <span class="operator">==</span> <span class="name">Loader</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-loader.html">Loader</a></span> {
      <span class="name">id</span>: <span class="name">loader</span>
      <span class="name">onStatusChanged</span>: <span class="keyword">if</span> (<span class="name">loader</span>.<span class="name">status</span> <span class="operator">==</span> <span class="name">Loader</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">loader</span>.<span class="name">status</span> <span class="operator">==</span> <span class="name">Loader</span>.<span class="name">Ready</span> ? <span class="string">'Loaded'</span> : <span class="string">'Not loaded'</span> }

</pre>
</li>
</ul>
<p>Note that if the source is a local file, the status will initially be Ready (or Error). While there will be no onStatusChanged signal in that case, the onLoaded will still be invoked.</p>
<p><b>See also </b><a href="qml-qtquick-loader.html#progress-prop">progress</a>.</p>
</div></div><!-- @@@status -->
<br/>
<h2>Signal Documentation</h2>
<!-- $$$loaded -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="loaded-signal">
<td class="tblQmlFuncNode"><p>
<a name="loaded-signal"></a><span class="name">loaded</span>()</p></td></tr>
</table></div>
</div><div class="qmldoc"><p>This signal is emitted when the <a href="qml-qtquick-loader.html#status-prop">status</a> becomes <code>Loader.Ready</code>, or on successful initial load.</p>
<p>The corresponding handler is <code>onLoaded</code>.</p>
</div></div><!-- @@@loaded -->
<br/>
<h2>Method Documentation</h2>
<!-- $$$setSource -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="setSource-method">
<td class="tblQmlFuncNode"><p>
<a name="setSource-method"></a><span class="type">object</span> <span class="name">setSource</span>(<span class="type">url</span> <i>source</i>, <span class="type">object</span> <i>properties</i>)</p></td></tr>
</table></div>
</div><div class="qmldoc"><p>Creates an object instance of the given <i>source</i> component that will have the given <i>properties</i>. The <i>properties</i> argument is optional. The instance will be accessible via the <a href="qml-qtquick-loader.html#item-prop">item</a> property once loading and instantiation is complete.</p>
<p>If the <a href="qml-qtquick-loader.html#active-prop">active</a> property is <code>false</code> at the time when this function is called, the given <i>source</i> component will not be loaded but the <i>source</i> and initial <i>properties</i> will be cached. When the loader is made <a href="qml-qtquick-loader.html#active-prop">active</a>, an instance of the <i>source</i> component will be created with the initial <i>properties</i> set.</p>
<p>Setting the initial property values of an instance of a component in this manner will <b>not</b> trigger any associated <a href="qml-qtquick-behavior.html">Behavior</a>s.</p>
<p>Note that the cached <i>properties</i> will be cleared if the <a href="qml-qtquick-loader.html#source-prop">source</a> or <a href="qml-qtquick-loader.html#sourceComponent-prop">sourceComponent</a> is changed after calling this function but prior to setting the loader <a href="qml-qtquick-loader.html#active-prop">active</a>.</p>
<p>Example:</p>
<div class="table"><table class="generic" width="70%">
 <tr valign="top" class="odd"><td ><pre class="qml">

  <span class="comment">// ExampleComponent.qml</span>
  import QtQuick 2.0
  <span class="type"><a href="qml-qtquick-rectangle.html">Rectangle</a></span> {
      <span class="name">id</span>: <span class="name">rect</span>
      <span class="name">color</span>: <span class="string">&quot;red&quot;</span>
      <span class="name">width</span>: <span class="number">10</span>
      <span class="name">height</span>: <span class="number">10</span>

      Behavior on <span class="name">color</span> {
          <span class="type"><a href="qml-qtquick-numberanimation.html">NumberAnimation</a></span> {
              <span class="name">target</span>: <span class="name">rect</span>
              <span class="name">property</span>: <span class="string">&quot;width&quot;</span>
              <span class="name">to</span>: (<span class="name">rect</span>.<span class="name">width</span> <span class="operator">+</span> <span class="number">20</span>)
              <span class="name">duration</span>: <span class="number">0</span>
          }
      }
  }

</pre>
</td><td ><pre class="qml">

  <span class="comment">// example.qml</span>
  import QtQuick 2.0
  <span class="type"><a href="qml-qtquick-item.html">Item</a></span> {
      <span class="type"><a href="qml-qtquick-loader.html">Loader</a></span> {
          <span class="name">id</span>: <span class="name">squareLoader</span>
          <span class="name">onLoaded</span>: <span class="name">console</span>.<span class="name">log</span>(<span class="name">squareLoader</span>.<span class="name">item</span>.<span class="name">width</span>);
          <span class="comment">// prints [10], not [30]</span>
      }

      <span class="name">Component</span>.onCompleted: {
          <span class="name">squareLoader</span>.<span class="name">setSource</span>(<span class="string">&quot;ExampleComponent.qml&quot;</span>,
                               { &quot;color&quot;: <span class="string">&quot;blue&quot;</span> });
          <span class="comment">// will trigger the onLoaded code when complete.</span>
      }
  }

</pre>
</td></tr>
</table></div>
<p><b>See also </b><a href="qml-qtquick-loader.html#source-prop">source</a> and <a href="qml-qtquick-loader.html#active-prop">active</a>.</p>
</div></div><!-- @@@setSource -->
<br/>
        </div>
       </div>
   </div>
   </div>
</div>
<div class="footer">
   <p>
   <acronym title="Copyright">&copy;</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>