Sophie

Sophie

distrib > Mageia > 7 > x86_64 > by-pkgid > 1dd17e0d683ef79b4bb6872bbf359d7f > files > 5864

qt4-doc-4.8.7-26.2.mga7.noarch.rpm

<?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" />
<!-- qdeclarativeloader.cpp -->
  <title>Qt 4.8: QML Loader Element</title>
  <link rel="stylesheet" type="text/css" href="style/style.css" />
  <script src="scripts/jquery.js" type="text/javascript"></script>
  <script src="scripts/functions.js" type="text/javascript"></script>
  <link rel="stylesheet" type="text/css" href="style/superfish.css" />
  <link rel="stylesheet" type="text/css" href="style/narrow.css" />
  <!--[if IE]>
<meta name="MSSmartTagsPreventParsing" content="true">
<meta http-equiv="imagetoolbar" content="no">
<![endif]-->
<!--[if lt IE 7]>
<link rel="stylesheet" type="text/css" href="style/style_ie6.css">
<![endif]-->
<!--[if IE 7]>
<link rel="stylesheet" type="text/css" href="style/style_ie7.css">
<![endif]-->
<!--[if IE 8]>
<link rel="stylesheet" type="text/css" href="style/style_ie8.css">
<![endif]-->

<script src="scripts/superfish.js" type="text/javascript"></script>
<script src="scripts/narrow.js" type="text/javascript"></script>

</head>
<body class="" onload="CheckEmptyAndLoadList();">
 <div class="header" id="qtdocheader">
    <div class="content"> 
    <div id="nav-logo">
      <a href="index.html">Home</a></div>
    <a href="index.html" class="qtref"><span>Qt Reference Documentation</span></a>
    <div id="narrowsearch"></div>
    <div id="nav-topright">
      <ul>
        <li class="nav-topright-home"><a href="http://qt.digia.com/">Qt HOME</a></li>
        <li class="nav-topright-dev"><a href="http://qt-project.org/">DEV</a></li>
        <li class="nav-topright-doc nav-topright-doc-active"><a href="http://qt-project.org/doc/">
          DOC</a></li>
        <li class="nav-topright-blog"><a href="http://blog.qt.digia.com/">BLOG</a></li>
      </ul>
    </div>
    <div id="shortCut">
      <ul>
        <li class="shortCut-topleft-inactive"><span><a href="index.html">Qt 4.8</a></span></li>
        <li class="shortCut-topleft-active"><a href="http://qt-project.org/doc/">ALL VERSIONS        </a></li>
      </ul>
     </div>
 <ul class="sf-menu" id="narrowmenu"> 
             <li><a href="#">API Lookup</a> 
                 <ul> 
                     <li><a href="classes.html">Class index</a></li> 
           <li><a href="functions.html">Function index</a></li> 
           <li><a href="modules.html">Modules</a></li> 
           <li><a href="namespaces.html">Namespaces</a></li> 
           <li><a href="qtglobal.html">Global Declarations</a></li> 
           <li><a href="qdeclarativeelements.html">QML elements</a></li> 
             </ul> 
             </li> 
             <li><a href="#">Qt Topics</a> 
                 <ul> 
                        <li><a href="qt-basic-concepts.html">Programming with Qt</a></li>  
                        <li><a href="qtquick.html">Device UIs &amp; Qt Quick</a></li>  
                        <li><a href="qt-gui-concepts.html">UI Design with Qt</a></li>  
                        <li><a href="supported-platforms.html">Supported Platforms</a></li>  
                        <li><a href="technology-apis.html">Qt and Key Technologies</a></li>  
                        <li><a href="best-practices.html">How-To's and Best Practices</a></li>  
              </ul> 
                 </li> 
                 <li><a href="#">Examples</a> 
                     <ul> 
                       <li><a href="all-examples.html">Examples</a></li> 
                       <li><a href="tutorials.html">Tutorials</a></li> 
                       <li><a href="demos.html">Demos</a></li> 
                       <li><a href="qdeclarativeexamples.html">QML Examples</a></li> 
                </ul> 
                     </li> 
                 </ul> 
    </div>
  </div>
  <div class="wrapper">
    <div class="hd">
      <span></span>
    </div>
    <div class="bd group">
      <div class="sidebar">
        <div class="searchlabel">
          Search index:</div>
        <div class="search" id="sidebarsearch">
          <form id="qtdocsearch" action="" onsubmit="return false;">
            <fieldset>
              <input type="text" name="searchstring" id="pageType" value="" />
 <div id="resultdialog"> 
 <a href="#" id="resultclose">Close</a> 
 <p id="resultlinks" class="all"><a href="#" id="showallresults">All</a> | <a href="#" id="showapiresults">API</a> | <a href="#" id="showarticleresults">Articles</a> | <a href="#" id="showexampleresults">Examples</a></p> 
 <p id="searchcount" class="all"><span id="resultcount"></span><span id="apicount"></span><span id="articlecount"></span><span id="examplecount"></span>&nbsp;results:</p> 
 <ul id="resultlist" class="all"> 
 </ul> 
 </div> 
            </fieldset>
          </form>
        </div>
        <div class="box first bottombar" id="lookup">
          <h2 title="API Lookup"><span></span>
            API Lookup</h2>
          <div  id="list001" class="list">
          <ul id="ul001" >
              <li class="defaultLink"><a href="classes.html">Class index</a></li>
              <li class="defaultLink"><a href="functions.html">Function index</a></li>
              <li class="defaultLink"><a href="modules.html">Modules</a></li>
              <li class="defaultLink"><a href="namespaces.html">Namespaces</a></li>
              <li class="defaultLink"><a href="qtglobal.html">Global Declarations</a></li>
              <li class="defaultLink"><a href="qdeclarativeelements.html">QML elements</a></li>
            </ul> 
          </div>
        </div>
        <div class="box bottombar" id="topics">
          <h2 title="Qt Topics"><span></span>
            Qt Topics</h2>
          <div id="list002" class="list">
            <ul id="ul002" >
               <li class="defaultLink"><a href="qt-basic-concepts.html">Programming with Qt</a></li> 
               <li class="defaultLink"><a href="qtquick.html">Device UIs &amp; Qt Quick</a></li> 
               <li class="defaultLink"><a href="qt-gui-concepts.html">UI Design with Qt</a></li> 
               <li class="defaultLink"><a href="supported-platforms.html">Supported Platforms</a></li>  
               <li class="defaultLink"><a href="technology-apis.html">Qt and Key Technologies</a></li> 
               <li class="defaultLink"><a href="best-practices.html">How-To's and Best Practices</a></li> 
            </ul>  
          </div>
        </div>
        <div class="box" id="examples">
          <h2 title="Examples"><span></span>
            Examples</h2>
          <div id="list003" class="list">
        <ul id="ul003">
              <li class="defaultLink"><a href="all-examples.html">Examples</a></li>
              <li class="defaultLink"><a href="tutorials.html">Tutorials</a></li>
              <li class="defaultLink"><a href="demos.html">Demos</a></li>
              <li class="defaultLink"><a href="qdeclarativeexamples.html">QML Examples</a></li>
            </ul> 
          </div>
        </div>
      </div>
      <div class="wrap">
        <div class="toolbar">
          <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 Loader Element</li>
            </ul>
          </div>
          <div class="toolbuttons toolblock">
            <ul>
              <li id="smallA" class="t_button">A</li>
              <li id="medA" class="t_button active">A</li>
              <li id="bigA" class="t_button">A</li>
              <li id="print" class="t_button"><a href="javascript:this.print();">
                <span>Print</span></a></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="#signal-handlers">Signal Handlers</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-items">Receiving signals from loaded items</a></li>
<li class="level2"><a href="#focus-and-key-events">Focus and key events</a></li>
</ul>
</div>
<h1 class="title">QML Loader Element</h1>
<span class="subtitle"></span>
<!-- $$$Loader-brief -->
<p>The Loader item allows dynamically loading an Item-based subtree from a URL or Component. <a href="#details">More...</a></p>
<!-- @@@Loader -->
<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-loader-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-loader.html#item-prop">item</a></b></b> : Item</li>
<li class="fn"><b><b><a href="qml-loader.html#progress-prop">progress</a></b></b> : real</li>
<li class="fn"><b><b><a href="qml-loader.html#source-prop">source</a></b></b> : url</li>
<li class="fn"><b><b><a href="qml-loader.html#sourceComponent-prop">sourceComponent</a></b></b> : Component</li>
<li class="fn"><b><b><a href="qml-loader.html#status-prop">status</a></b></b> : enumeration</li>
</ul>
<a name="signal-handlers"></a>
<h2>Signal Handlers</h2>
<ul>
<li class="fn"><b><b><a href="qml-loader.html#onLoaded-signal">onLoaded</a></b></b></li>
</ul>
<!-- $$$Loader-description -->
<a name="details"></a>
<h2>Detailed Description</h2>
<p>Loader is used to dynamically load visual QML components. It can load a QML file (using the <a href="qml-loader.html#source-prop">source</a> property) or a <a href="qml-component.html">Component</a> object (using the <a href="qml-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-mousearea.html">MouseArea</a> is clicked:</p>
<pre class="qml"> import QtQuick 1.0

 <span class="type"><a href="qml-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">Loader</span> { <span class="name">id</span>: <span class="name">pageLoader</span> }

     <span class="type"><a href="qml-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 item can be accessed using the <a href="qml-loader.html#item-prop">item</a> property.</p>
<p>If the <a href="qml-loader.html#source-prop">source</a> or <a href="qml-loader.html#sourceComponent-prop">sourceComponent</a> changes, any previously instantiated items are destroyed. Setting <a href="qml-loader.html#source-prop">source</a> to an empty string or setting <a href="qml-loader.html#sourceComponent-prop">sourceComponent</a> to <tt>undefined</tt> destroys the currently loaded item, freeing resources and leaving the Loader empty.</p>
<a name="loader-sizing-behavior"></a>
<h3>Loader sizing behavior</h3>
<p>Loader is like any other visual item and must be positioned and sized accordingly to become visible.</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>
<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 1.0

 <span class="type"><a href="qml-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">Loader</span> {
         <span class="comment">// Explicitly set the size of the 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"><a href="qml-component.html">Component</a></span> {
         <span class="name">id</span>: <span class="name">rect</span>
         <span class="type"><a href="qml-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 1.0

 <span class="type"><a href="qml-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">Loader</span> {
         <span class="comment">// position the Loader in the center 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"><a href="qml-component.html">Component</a></span> {
         <span class="name">id</span>: <span class="name">rect</span>
         <span class="type"><a href="qml-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>
<a name="receiving-signals-from-loaded-items"></a>
<h3>Receiving signals from loaded items</h3>
<p>Any signals emitted from the loaded item can be received using the <a href="qml-connections.html">Connections</a> element. For example, the following <tt>application.qml</tt> loads <tt>MyItem.qml</tt>, and is able to receive the <tt>message</tt> signal from the loaded item through a <a href="qml-connections.html">Connections</a> object:</p>
<table class="generic">
<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 1.0

 <span class="type"><a href="qml-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">Loader</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"><a href="qml-connections.html">Connections</a></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 1.0

 <span class="type"><a href="qml-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-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>
<p>Alternatively, since <tt>MyItem.qml</tt> 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-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-item.html#focus-prop">focus</a> property must be set to <tt>true</tt> for any of its children to get the <i>active focus</i>. (See <a href="qdeclarativefocus.html#acquiring-focus-and-focus-scopes">the focus documentation page</a> for more details.) Any key events received in the loaded item should likely also be <a href="qml-keyevent.html#accepted-prop">accepted</a> so they are not propagated to the Loader.</p>
<p>For example, the following <tt>application.qml</tt> loads <tt>KeyReader.qml</tt> when the <a href="qml-mousearea.html">MouseArea</a> is clicked. Notice the <a href="qml-item.html#focus-prop">focus</a> property is set to <tt>true</tt> for the Loader as well as the <a href="qml-item.html">Item</a> in the dynamically loaded object:</p>
<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 1.0

 <span class="type"><a href="qml-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">Loader</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-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 1.0

 <span class="type"><a href="qml-item.html">Item</a></span> {
     <span class="type"><a href="qml-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;Loaded item 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>
<p>Once <tt>KeyReader.qml</tt> is loaded, it accepts key events and sets <tt>event.accepted</tt> to <tt>true</tt> so that the event is not propagated to the parent <a href="qml-rectangle.html">Rectangle</a>.</p>
<p><b>See also </b><a href="qml-qt.html#dynamic-object-creation">Dynamic Object Creation</a>.</p>
<!-- @@@Loader -->
<h2>Property Documentation</h2>
<!-- $$$item -->
<div class="qmlitem"><div class="qmlproto"><table class="qmlname"><tr valign="top" class="odd"><td class="tblQmlPropNode"><p><a name="item-prop"></a><span class="qmlreadonly">read-only</span><span class="name">item</span> : <span class="type"><a href="qml-item.html">Item</a></span></p></td></tr></table></div><div class="qmldoc"><p>This property holds the top-level item that is currently loaded.</p>
</div></div><!-- @@@item -->
<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 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-loader.html#status-prop">status</a>.</p>
</div></div><!-- @@@progress -->
<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 of the QML component to instantiate.</p>
<p>Note the QML component must be an <a href="qml-item.html">Item</a>-based component. The loader cannot load non-visual components.</p>
<p>To unload the currently loaded item, set this property to an empty string, or set <a href="qml-loader.html#sourceComponent-prop">sourceComponent</a> to <tt>undefined</tt>. Setting <tt>source</tt> 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-loader.html#sourceComponent-prop">sourceComponent</a>, <a href="qml-loader.html#status-prop">status</a>, and <a href="qml-loader.html#progress-prop">progress</a>.</p>
</div></div><!-- @@@source -->
<br/>
<!-- $$$sourceComponent -->
<div class="qmlitem"><div class="qmlproto"><table class="qmlname"><tr valign="top" class="odd"><td class="tblQmlPropNode"><p><a name="sourceComponent-prop"></a><span class="name">sourceComponent</span> : <span class="type"><a href="qml-component.html">Component</a></span></p></td></tr></table></div><div class="qmldoc"><p>This property holds the <a href="qml-component.html">Component</a> to instantiate.</p>
<pre class="qml"> <span class="type"><a href="qml-item.html">Item</a></span> {
     <span class="type"><a href="qml-component.html">Component</a></span> {
         <span class="name">id</span>: <span class="name">redSquare</span>
         <span class="type"><a href="qml-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-loader.html">Loader</a></span> { <span class="name">sourceComponent</span>: <span class="name">redSquare</span> }
     <span class="type"><a href="qml-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 item, set this property to an empty string or <tt>undefined</tt>.</p>
<p><b>See also </b><a href="qml-loader.html#source-prop">source</a> and <a href="qml-loader.html#progress-prop">progress</a>.</p>
</div></div><!-- @@@sourceComponent -->
<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 holds the status of QML loading. It can be one of:</p>
<ul>
<li>Loader.Null - 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-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 <tt>onStatusChanged</tt> signal handler:<pre class="qml"> <span class="type"><a href="qml-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-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 <a href="qml-loader.html#onLoaded-signal">onLoaded</a> will still be invoked.</p>
<p><b>See also </b><a href="qml-loader.html#progress-prop">progress</a>.</p>
</div></div><!-- @@@status -->
<br/>
<h2>Signal Handler Documentation</h2>
<!-- $$$onLoaded -->
<div class="qmlitem"><div class="qmlproto"><table class="qmlname"><tr valign="top" class="odd"><td class="tblQmlFuncNode"><p><a name="onLoaded-signal"></a>Loader::<span class="name">onLoaded</span> ()</p></td></tr></table></div><div class="qmldoc"><p>This handler is called when the <a href="qml-loader.html#status-prop">status</a> becomes <tt>Loader.Ready</tt>, or on successful initial load.</p>
</div></div><!-- @@@onLoaded -->
<br/>
<p class="naviNextPrevious footerNavi">
</p>
      </div>
    </div>
    </div> 
    <div class="ft">
      <span></span>
    </div>
  </div> 
  <div class="footer">
    <p>
      <acronym title="Copyright">&copy;</acronym> 2015 The Qt Company Ltd.
      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>
      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. <a title="Privacy Policy"
      href="http://en.gitorious.org/privacy_policy/">Privacy Policy</a></p>
  </div>

  <script src="scripts/functions.js" type="text/javascript"></script>
</body>
</html>