Sophie

Sophie

distrib > Mageia > 7 > i586 > media > core-updates > by-pkgid > 6e2327ca1c896c6d674ae53117299f21 > files > 152

qtdeclarative5-doc-5.12.6-1.mga7.noarch.rpm

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- qqmlcomponent.cpp -->
  <title>QQmlComponent Class | Qt QML 5.12.6</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.12</td><td ><a href="qtqml-index.html">Qt QML</a></td><td ><a href="qtqml-module.html">C++ Classes</a></td><td >QQmlComponent</td></tr></table><table class="buildversion"><tr>
<td id="buildversion" width="100%" align="right"><a href="qtqml-index.html">Qt 5.12.6 Reference Documentation</a></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="#public-types">Public Types</a></li>
<li class="level1"><a href="#properties">Properties</a></li>
<li class="level1"><a href="#public-functions">Public Functions</a></li>
<li class="level1"><a href="#public-slots">Public Slots</a></li>
<li class="level1"><a href="#signals">Signals</a></li>
<li class="level1"><a href="#static-public-members">Static Public Members</a></li>
<li class="level1"><a href="#details">Detailed Description</a></li>
<li class="level2"><a href="#network-components">Network Components</a></li>
</ul>
</div>
<div class="sidebar-content" id="sidebar-content"></div></div>
<h1 class="title">QQmlComponent Class</h1>
<!-- $$$QQmlComponent-brief -->
<p>The <a href="qqmlcomponent.html">QQmlComponent</a> class encapsulates a QML component definition. <a href="#details">More...</a></p>
<!-- @@@QQmlComponent -->
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> Header:</td><td class="memItemRight bottomAlign">   <span class="preprocessor">#include &lt;QQmlComponent&gt;</span>
</td></tr><tr><td class="memItemLeft rightAlign topAlign"> qmake:</td><td class="memItemRight bottomAlign"> QT += qml</td></tr><tr><td class="memItemLeft rightAlign topAlign"> Since:</td><td class="memItemRight bottomAlign">  Qt 5.0</td></tr><tr><td class="memItemLeft rightAlign topAlign"> Instantiated By:</td><td class="memItemRight bottomAlign"> <a href="qml-qtqml-component.html">Component</a></td></tr></table></div><ul>
<li><a href="qqmlcomponent-members.html">List of all members, including inherited members</a></li>
</ul>
<a name="public-types"></a>
<h2 id="public-types">Public Types</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> enum </td><td class="memItemRight bottomAlign"><b><a href="qqmlcomponent.html#CompilationMode-enum">CompilationMode</a></b> { PreferSynchronous, Asynchronous }</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> enum </td><td class="memItemRight bottomAlign"><b><a href="qqmlcomponent.html#Status-enum">Status</a></b> { Null, Ready, Loading, Error }</td></tr>
</table></div>
<a name="properties"></a>
<h2 id="properties">Properties</h2>
<ul>
<li class="fn"><b><a href="qqmlcomponent.html#progress-prop">progress</a></b> : const qreal</li>
<li class="fn"><b><a href="qqmlcomponent.html#status-prop">status</a></b> : const Status</li>
<li class="fn"><b><a href="qqmlcomponent.html#url-prop">url</a></b> : const QUrl</li>
</ul>
<a name="public-functions"></a>
<h2 id="public-functions">Public Functions</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qqmlcomponent.html#QQmlComponent">QQmlComponent</a></b>(QQmlEngine *<i>engine</i>, QObject *<i>parent</i> = nullptr)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qqmlcomponent.html#QQmlComponent-2">QQmlComponent</a></b>(QQmlEngine *<i>engine</i>, const QString &amp;<i>fileName</i>, QObject *<i>parent</i> = nullptr)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qqmlcomponent.html#QQmlComponent-3">QQmlComponent</a></b>(QQmlEngine *<i>engine</i>, const QString &amp;<i>fileName</i>, QQmlComponent::CompilationMode <i>mode</i>, QObject *<i>parent</i> = nullptr)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qqmlcomponent.html#QQmlComponent-4">QQmlComponent</a></b>(QQmlEngine *<i>engine</i>, const QUrl &amp;<i>url</i>, QObject *<i>parent</i> = nullptr)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qqmlcomponent.html#QQmlComponent-5">QQmlComponent</a></b>(QQmlEngine *<i>engine</i>, const QUrl &amp;<i>url</i>, QQmlComponent::CompilationMode <i>mode</i>, QObject *<i>parent</i> = nullptr)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual </td><td class="memItemRight bottomAlign"><b><a href="qqmlcomponent.html#dtor.QQmlComponent">~QQmlComponent</a></b>() override</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual QObject *</td><td class="memItemRight bottomAlign"><b><a href="qqmlcomponent.html#beginCreate">beginCreate</a></b>(QQmlContext *<i>publicContext</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual void </td><td class="memItemRight bottomAlign"><b><a href="qqmlcomponent.html#completeCreate">completeCreate</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual QObject *</td><td class="memItemRight bottomAlign"><b><a href="qqmlcomponent.html#create">create</a></b>(QQmlContext *<i>context</i> = nullptr)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qqmlcomponent.html#create-1">create</a></b>(QQmlIncubator &amp;<i>incubator</i>, QQmlContext *<i>context</i> = nullptr, QQmlContext *<i>forContext</i> = nullptr)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QQmlContext *</td><td class="memItemRight bottomAlign"><b><a href="qqmlcomponent.html#creationContext">creationContext</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QQmlEngine *</td><td class="memItemRight bottomAlign"><b><a href="qqmlcomponent.html#engine">engine</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QList&lt;QQmlError&gt; </td><td class="memItemRight bottomAlign"><b><a href="qqmlcomponent.html#errors">errors</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qqmlcomponent.html#isError">isError</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qqmlcomponent.html#isLoading">isLoading</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qqmlcomponent.html#isNull">isNull</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qqmlcomponent.html#isReady">isReady</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> qreal </td><td class="memItemRight bottomAlign"><b><a href="qqmlcomponent.html#progress-prop">progress</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QQmlComponent::Status </td><td class="memItemRight bottomAlign"><b><a href="qqmlcomponent.html#status-prop">status</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QUrl </td><td class="memItemRight bottomAlign"><b><a href="qqmlcomponent.html#url-prop">url</a></b>() const</td></tr>
</table></div>
<a name="public-slots"></a>
<h2 id="public-slots">Public Slots</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qqmlcomponent.html#loadUrl">loadUrl</a></b>(const QUrl &amp;<i>url</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qqmlcomponent.html#loadUrl-1">loadUrl</a></b>(const QUrl &amp;<i>url</i>, QQmlComponent::CompilationMode <i>mode</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qqmlcomponent.html#setData">setData</a></b>(const QByteArray &amp;<i>data</i>, const QUrl &amp;<i>url</i>)</td></tr>
</table></div>
<a name="signals"></a>
<h2 id="signals">Signals</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qqmlcomponent.html#progressChanged">progressChanged</a></b>(qreal <i>progress</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qqmlcomponent.html#statusChanged">statusChanged</a></b>(QQmlComponent::Status <i>status</i>)</td></tr>
</table></div>
<a name="static-public-members"></a>
<h2 id="static-public-members">Static Public Members</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> const QMetaObject </td><td class="memItemRight bottomAlign"><b><a href="qqmlcomponent.html#staticMetaObject-var">staticMetaObject</a></b></td></tr>
</table></div>
<a name="details"></a>
<!-- $$$QQmlComponent-description -->
<div class="descr">
<h2 id="details">Detailed Description</h2>
<p>The <a href="qqmlcomponent.html">QQmlComponent</a> class encapsulates a QML component definition.</p>
<p>Components are reusable, encapsulated QML types with well-defined interfaces.</p>
<p>A <a href="qqmlcomponent.html">QQmlComponent</a> instance can be created from a QML file. For example, if there is a <code>main.qml</code> file like this:</p>
<pre class="qml">



</pre>
<p>The following code loads this QML file as a component, creates an instance of this component using <a href="qqmlcomponent.html#create">create</a>(), and then queries the Item's width value:</p>
<pre class="cpp">

  <span class="type"><a href="qqmlengine.html">QQmlEngine</a></span> <span class="operator">*</span>engine <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qqmlengine.html">QQmlEngine</a></span>;
  <span class="type"><a href="qqmlcomponent.html#QQmlComponent">QQmlComponent</a></span> component(engine<span class="operator">,</span> <span class="type">QUrl</span><span class="operator">::</span>fromLocalFile(<span class="string">&quot;main.qml&quot;</span>));

  <span class="type">QObject</span> <span class="operator">*</span>myObject <span class="operator">=</span> component<span class="operator">.</span>create();
  <span class="type">QQuickItem</span> <span class="operator">*</span>item <span class="operator">=</span> qobject_cast<span class="operator">&lt;</span><span class="type">QQuickItem</span><span class="operator">*</span><span class="operator">&gt;</span>(myObject);
  <span class="type">int</span> width <span class="operator">=</span> item<span class="operator">-</span><span class="operator">&gt;</span>width();  <span class="comment">// width = 200</span>

</pre>
<p>To create instances of a component in code where a <a href="qqmlengine.html">QQmlEngine</a> instance is not available, you can use <a href="qqmlengine.html#qmlContext">qmlContext</a>() or <a href="qqmlengine.html#qmlEngine">qmlEngine</a>(). For example, in the scenario below, child items are being created within a QQuickItem subclass:</p>
<pre class="cpp">

  <span class="type">void</span> MyCppItem<span class="operator">::</span>init()
  {
      <span class="type"><a href="qqmlengine.html">QQmlEngine</a></span> <span class="operator">*</span>engine <span class="operator">=</span> qmlEngine(<span class="keyword">this</span>);
      <span class="comment">// Or:</span>
      <span class="comment">// QQmlEngine *engine = qmlContext(this)-&gt;engine();</span>
      <span class="type"><a href="qqmlcomponent.html#QQmlComponent">QQmlComponent</a></span> component(engine<span class="operator">,</span> <span class="type">QUrl</span><span class="operator">::</span>fromLocalFile(<span class="string">&quot;MyItem.qml&quot;</span>));
      <span class="type">QQuickItem</span> <span class="operator">*</span>childItem <span class="operator">=</span> qobject_cast<span class="operator">&lt;</span><span class="type">QQuickItem</span><span class="operator">*</span><span class="operator">&gt;</span>(component<span class="operator">.</span>create());
      childItem<span class="operator">-</span><span class="operator">&gt;</span>setParentItem(<span class="keyword">this</span>);
  }

</pre>
<p>Note that these functions will return <code>null</code> when called inside the constructor of a QObject subclass, as the instance will not yet have a context nor engine.</p>
<a name="network-components"></a>
<h4 id="network-components">Network Components</h4>
<p>If the URL passed to <a href="qqmlcomponent.html">QQmlComponent</a> is a network resource, or if the QML document references a network resource, the <a href="qqmlcomponent.html">QQmlComponent</a> has to fetch the network data before it is able to create objects. In this case, the <a href="qqmlcomponent.html">QQmlComponent</a> will have a <a href="qqmlcomponent.html#Status-enum">Loading</a> <a href="qqmlcomponent.html#status-prop">status</a>. An application will have to wait until the component is <a href="qqmlcomponent.html#Status-enum">Ready</a> before calling <a href="qqmlcomponent.html#create">QQmlComponent::create</a>().</p>
<p>The following example shows how to load a QML file from a network resource. After creating the <a href="qqmlcomponent.html">QQmlComponent</a>, it tests whether the component is loading. If it is, it connects to the <a href="qqmlcomponent.html#statusChanged">QQmlComponent::statusChanged</a>() signal and otherwise calls the <code>continueLoading()</code> method directly. Note that <a href="qqmlcomponent.html#isLoading">QQmlComponent::isLoading</a>() may be false for a network component if the component has been cached and is ready immediately.</p>
<pre class="cpp">

  MyApplication<span class="operator">::</span>MyApplication()
  {
      <span class="comment">// ...</span>
      component <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qqmlcomponent.html#QQmlComponent">QQmlComponent</a></span>(engine<span class="operator">,</span> <span class="type">QUrl</span>(<span class="string">&quot;http://www.example.com/main.qml&quot;</span>));
      <span class="keyword">if</span> (component<span class="operator">-</span><span class="operator">&gt;</span>isLoading())
          <span class="type">QObject</span><span class="operator">::</span>connect(component<span class="operator">,</span> SIGNAL(statusChanged(<span class="type"><a href="qqmlcomponent.html#QQmlComponent">QQmlComponent</a></span><span class="operator">::</span>Status))<span class="operator">,</span>
                           <span class="keyword">this</span><span class="operator">,</span> SLOT(continueLoading()));
      <span class="keyword">else</span>
          continueLoading();
  }

  <span class="type">void</span> MyApplication<span class="operator">::</span>continueLoading()
  {
      <span class="keyword">if</span> (component<span class="operator">-</span><span class="operator">&gt;</span>isError()) {
          qWarning() <span class="operator">&lt;</span><span class="operator">&lt;</span> component<span class="operator">-</span><span class="operator">&gt;</span>errors();
      } <span class="keyword">else</span> {
          <span class="type">QObject</span> <span class="operator">*</span>myObject <span class="operator">=</span> component<span class="operator">-</span><span class="operator">&gt;</span>create();
      }
  }

</pre>
</div>
<!-- @@@QQmlComponent -->
<div class="types">
<h2>Member Type Documentation</h2>
<!-- $$$CompilationMode$$$PreferSynchronous$$$Asynchronous -->
<h3 class="fn" id="CompilationMode-enum"><a name="CompilationMode-enum"></a>enum QQmlComponent::<span class="name">CompilationMode</span></h3>
<p>Specifies whether the <a href="qqmlcomponent.html">QQmlComponent</a> should load the component immediately, or asynchonously.</p>
<div class="table"><table class="valuelist"><tr valign="top" class="odd"><th class="tblConst">Constant</th><th class="tblval">Value</th><th class="tbldscr">Description</th></tr>
<tr><td class="topAlign"><code>QQmlComponent::PreferSynchronous</code></td><td class="topAlign tblval"><code>0</code></td><td class="topAlign">Prefer loading/compiling the component immediately, blocking the thread. This is not always possible; for example, remote URLs will always load asynchronously.</td></tr>
<tr><td class="topAlign"><code>QQmlComponent::Asynchronous</code></td><td class="topAlign tblval"><code>1</code></td><td class="topAlign">Load/compile the component in a background thread.</td></tr>
</table></div>
<!-- @@@CompilationMode -->
<!-- $$$Status$$$Null$$$Ready$$$Loading$$$Error -->
<h3 class="fn" id="Status-enum"><a name="Status-enum"></a>enum QQmlComponent::<span class="name">Status</span></h3>
<p>Specifies the loading status of the <a href="qqmlcomponent.html">QQmlComponent</a>.</p>
<div class="table"><table class="valuelist"><tr valign="top" class="odd"><th class="tblConst">Constant</th><th class="tblval">Value</th><th class="tbldscr">Description</th></tr>
<tr><td class="topAlign"><code>QQmlComponent::Null</code></td><td class="topAlign tblval"><code>0</code></td><td class="topAlign">This <a href="qqmlcomponent.html">QQmlComponent</a> has no data. Call <a href="qqmlcomponent.html#loadUrl">loadUrl</a>() or <a href="qqmlcomponent.html#setData">setData</a>() to add QML content.</td></tr>
<tr><td class="topAlign"><code>QQmlComponent::Ready</code></td><td class="topAlign tblval"><code>1</code></td><td class="topAlign">This <a href="qqmlcomponent.html">QQmlComponent</a> is ready and <a href="qqmlcomponent.html#create">create</a>() may be called.</td></tr>
<tr><td class="topAlign"><code>QQmlComponent::Loading</code></td><td class="topAlign tblval"><code>2</code></td><td class="topAlign">This <a href="qqmlcomponent.html">QQmlComponent</a> is loading network data.</td></tr>
<tr><td class="topAlign"><code>QQmlComponent::Error</code></td><td class="topAlign tblval"><code>3</code></td><td class="topAlign">An error has occurred. Call <a href="qqmlcomponent.html#errors">errors</a>() to retrieve a list of <a href="qqmlerror.html">errors</a>.</td></tr>
</table></div>
<!-- @@@Status -->
</div>
<div class="prop">
<h2>Property Documentation</h2>
<!-- $$$progress-prop$$$progress$$$progressChangedqreal -->
<h3 class="fn" id="progress-prop"><a name="progress-prop"></a><span class="name">progress</span> : const <span class="type">qreal</span></h3>
<p>The progress of loading the component, from 0.0 (nothing loaded) to 1.0 (finished).</p>
<p><b>Access functions:</b></p>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft topAlign rightAlign"> qreal </td><td class="memItemRight bottomAlign"><span class="name"><b>progress</b></span>() const</td></tr>
</table></div>
<p><b>Notifier signal:</b></p>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft topAlign rightAlign"> void </td><td class="memItemRight bottomAlign"><span class="name"><b><a href="qqmlcomponent.html#progressChanged">progressChanged</a></b></span>(qreal <i>progress</i>)</td></tr>
</table></div>
<!-- @@@progress -->
<!-- $$$status-prop$$$status$$$statusChangedQQmlComponent::Status -->
<h3 class="fn" id="status-prop"><a name="status-prop"></a><span class="name">status</span> : const <span class="type"><a href="qqmlcomponent.html#Status-enum">Status</a></span></h3>
<p>The component's current <a href="qqmlcomponent.html#Status-enum">status</a>.</p>
<p><b>Access functions:</b></p>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft topAlign rightAlign"> QQmlComponent::Status </td><td class="memItemRight bottomAlign"><span class="name"><b>status</b></span>() const</td></tr>
</table></div>
<p><b>Notifier signal:</b></p>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft topAlign rightAlign"> void </td><td class="memItemRight bottomAlign"><span class="name"><b><a href="qqmlcomponent.html#statusChanged">statusChanged</a></b></span>(QQmlComponent::Status <i>status</i>)</td></tr>
</table></div>
<!-- @@@status -->
<!-- $$$url-prop$$$url -->
<h3 class="fn" id="url-prop"><a name="url-prop"></a><span class="name">url</span> : const <span class="type">QUrl</span></h3>
<p>The component URL. This is the URL passed to either the constructor, or the <a href="qqmlcomponent.html#loadUrl">loadUrl</a>(), or <a href="qqmlcomponent.html#setData">setData</a>() methods.</p>
<p><b>Access functions:</b></p>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft topAlign rightAlign"> QUrl </td><td class="memItemRight bottomAlign"><span class="name"><b>url</b></span>() const</td></tr>
</table></div>
<!-- @@@url -->
</div>
<div class="func">
<h2>Member Function Documentation</h2>
<!-- $$$QQmlComponent[overload1]$$$QQmlComponentQQmlEngine*QObject* -->
<h3 class="fn" id="QQmlComponent"><a name="QQmlComponent"></a>QQmlComponent::<span class="name">QQmlComponent</span>(<span class="type"><a href="qqmlengine.html">QQmlEngine</a></span> *<i>engine</i>, <span class="type">QObject</span> *<i>parent</i> = nullptr)</h3>
<p>Create a <a href="qqmlcomponent.html">QQmlComponent</a> with no data and give it the specified <i>engine</i> and <i>parent</i>. Set the data with <a href="qqmlcomponent.html#setData">setData</a>().</p>
<!-- @@@QQmlComponent -->
<!-- $$$QQmlComponent$$$QQmlComponentQQmlEngine*constQString&QObject* -->
<h3 class="fn" id="QQmlComponent-2"><a name="QQmlComponent-2"></a>QQmlComponent::<span class="name">QQmlComponent</span>(<span class="type"><a href="qqmlengine.html">QQmlEngine</a></span> *<i>engine</i>, const <span class="type">QString</span> &amp;<i>fileName</i>, <span class="type">QObject</span> *<i>parent</i> = nullptr)</h3>
<p>Create a <a href="qqmlcomponent.html">QQmlComponent</a> from the given <i>fileName</i> and give it the specified <i>parent</i> and <i>engine</i>.</p>
<p><b>See also </b><a href="qqmlcomponent.html#loadUrl">loadUrl</a>().</p>
<!-- @@@QQmlComponent -->
<!-- $$$QQmlComponent$$$QQmlComponentQQmlEngine*constQString&QQmlComponent::CompilationModeQObject* -->
<h3 class="fn" id="QQmlComponent-3"><a name="QQmlComponent-3"></a>QQmlComponent::<span class="name">QQmlComponent</span>(<span class="type"><a href="qqmlengine.html">QQmlEngine</a></span> *<i>engine</i>, const <span class="type">QString</span> &amp;<i>fileName</i>, <span class="type"><a href="qqmlcomponent.html#CompilationMode-enum">QQmlComponent::CompilationMode</a></span> <i>mode</i>, <span class="type">QObject</span> *<i>parent</i> = nullptr)</h3>
<p>Create a <a href="qqmlcomponent.html">QQmlComponent</a> from the given <i>fileName</i> and give it the specified <i>parent</i> and <i>engine</i>. If <i>mode</i> is <a href="qqmlcomponent.html#CompilationMode-enum">Asynchronous</a>, the component will be loaded and compiled asynchronously.</p>
<p><b>See also </b><a href="qqmlcomponent.html#loadUrl">loadUrl</a>().</p>
<!-- @@@QQmlComponent -->
<!-- $$$QQmlComponent$$$QQmlComponentQQmlEngine*constQUrl&QObject* -->
<h3 class="fn" id="QQmlComponent-4"><a name="QQmlComponent-4"></a>QQmlComponent::<span class="name">QQmlComponent</span>(<span class="type"><a href="qqmlengine.html">QQmlEngine</a></span> *<i>engine</i>, const <span class="type">QUrl</span> &amp;<i>url</i>, <span class="type">QObject</span> *<i>parent</i> = nullptr)</h3>
<p>Create a <a href="qqmlcomponent.html">QQmlComponent</a> from the given <i>url</i> and give it the specified <i>parent</i> and <i>engine</i>.</p>
<p>Ensure that the URL provided is full and correct, in particular, use QUrl::fromLocalFile() when loading a file from the local filesystem.</p>
<p>Relative paths will be resolved against <a href="qqmlengine.html#baseUrl">QQmlEngine::baseUrl()</a>, which is the current working directory unless specified.</p>
<p><b>See also </b><a href="qqmlcomponent.html#loadUrl">loadUrl</a>().</p>
<!-- @@@QQmlComponent -->
<!-- $$$QQmlComponent$$$QQmlComponentQQmlEngine*constQUrl&QQmlComponent::CompilationModeQObject* -->
<h3 class="fn" id="QQmlComponent-5"><a name="QQmlComponent-5"></a>QQmlComponent::<span class="name">QQmlComponent</span>(<span class="type"><a href="qqmlengine.html">QQmlEngine</a></span> *<i>engine</i>, const <span class="type">QUrl</span> &amp;<i>url</i>, <span class="type"><a href="qqmlcomponent.html#CompilationMode-enum">QQmlComponent::CompilationMode</a></span> <i>mode</i>, <span class="type">QObject</span> *<i>parent</i> = nullptr)</h3>
<p>Create a <a href="qqmlcomponent.html">QQmlComponent</a> from the given <i>url</i> and give it the specified <i>parent</i> and <i>engine</i>. If <i>mode</i> is <a href="qqmlcomponent.html#CompilationMode-enum">Asynchronous</a>, the component will be loaded and compiled asynchronously.</p>
<p>Ensure that the URL provided is full and correct, in particular, use QUrl::fromLocalFile() when loading a file from the local filesystem.</p>
<p>Relative paths will be resolved against <a href="qqmlengine.html#baseUrl">QQmlEngine::baseUrl()</a>, which is the current working directory unless specified.</p>
<p><b>See also </b><a href="qqmlcomponent.html#loadUrl">loadUrl</a>().</p>
<!-- @@@QQmlComponent -->
<!-- $$$~QQmlComponent[overload1]$$$~QQmlComponent -->
<h3 class="fn" id="dtor.QQmlComponent"><a name="dtor.QQmlComponent"></a><code>[override virtual] </code>QQmlComponent::<span class="name">~QQmlComponent</span>()</h3>
<p>Destruct the <a href="qqmlcomponent.html">QQmlComponent</a>.</p>
<!-- @@@~QQmlComponent -->
<!-- $$$beginCreate[overload1]$$$beginCreateQQmlContext* -->
<h3 class="fn" id="beginCreate"><a name="beginCreate"></a><code>[virtual] </code><span class="type">QObject</span> *QQmlComponent::<span class="name">beginCreate</span>(<span class="type"><a href="qqmlcontext.html">QQmlContext</a></span> *<i>publicContext</i>)</h3>
<p>This method provides advanced control over component instance creation. In general, programmers should use <a href="qqmlcomponent.html#create">QQmlComponent::create</a>() to create object instances.</p>
<p>Create an object instance from this component. Returns <code>nullptr</code> if creation failed. <i>publicContext</i> specifies the context within which to create the object instance.</p>
<p>When <a href="qqmlcomponent.html">QQmlComponent</a> constructs an instance, it occurs in three steps:</p>
<ol class="1" type="1"><li>The object hierarchy is created, and constant values are assigned.</li>
<li>Property bindings are evaluated for the first time.</li>
<li>If applicable, <a href="qqmlparserstatus.html#componentComplete">QQmlParserStatus::componentComplete</a>() is called on objects.</li>
</ol>
<p>QQmlComponent::beginCreate() differs from <a href="qqmlcomponent.html#create">QQmlComponent::create</a>() in that it only performs step 1. <a href="qqmlcomponent.html#completeCreate">QQmlComponent::completeCreate</a>() must be called to complete steps 2 and 3.</p>
<p>This breaking point is sometimes useful when using attached properties to communicate information to an instantiated component, as it allows their initial values to be configured before property bindings take effect.</p>
<p>The ownership of the returned object instance is transferred to the caller.</p>
<p><b>See also </b><a href="qqmlcomponent.html#completeCreate">completeCreate</a>() and <a href="qqmlengine.html#ObjectOwnership-enum">QQmlEngine::ObjectOwnership</a>.</p>
<!-- @@@beginCreate -->
<!-- $$$completeCreate[overload1]$$$completeCreate -->
<h3 class="fn" id="completeCreate"><a name="completeCreate"></a><code>[virtual] </code><span class="type">void</span> QQmlComponent::<span class="name">completeCreate</span>()</h3>
<p>This method provides advanced control over component instance creation. In general, programmers should use <a href="qqmlcomponent.html#create">QQmlComponent::create</a>() to create a component.</p>
<p>This function completes the component creation begun with <a href="qqmlcomponent.html#beginCreate">QQmlComponent::beginCreate</a>() and must be called afterwards.</p>
<p><b>See also </b><a href="qqmlcomponent.html#beginCreate">beginCreate</a>().</p>
<!-- @@@completeCreate -->
<!-- $$$create[overload1]$$$createQQmlContext* -->
<h3 class="fn" id="create"><a name="create"></a><code>[virtual] </code><span class="type">QObject</span> *QQmlComponent::<span class="name">create</span>(<span class="type"><a href="qqmlcontext.html">QQmlContext</a></span> *<i>context</i> = nullptr)</h3>
<p>Create an object instance from this component. Returns <code>nullptr</code> if creation failed. <i>context</i> specifies the context within which to create the object instance.</p>
<p>If <i>context</i> is <code>nullptr</code> (the default), it will create the instance in the <a href="qqmlengine.html#rootContext">root context</a> of the engine.</p>
<p>The ownership of the returned object instance is transferred to the caller.</p>
<p>If the object being created from this component is a visual item, it must have a visual parent, which can be set by calling QQuickItem::setParentItem(). See Concepts - Visual Parent in Qt Quick for more details.</p>
<p><b>See also </b><a href="qqmlengine.html#ObjectOwnership-enum">QQmlEngine::ObjectOwnership</a>.</p>
<!-- @@@create -->
<!-- $$$create$$$createQQmlIncubator&QQmlContext*QQmlContext* -->
<h3 class="fn" id="create-1"><a name="create-1"></a><span class="type">void</span> QQmlComponent::<span class="name">create</span>(<span class="type"><a href="qqmlincubator.html">QQmlIncubator</a></span> &amp;<i>incubator</i>, <span class="type"><a href="qqmlcontext.html">QQmlContext</a></span> *<i>context</i> = nullptr, <span class="type"><a href="qqmlcontext.html">QQmlContext</a></span> *<i>forContext</i> = nullptr)</h3>
<p>Create an object instance from this component using the provided <i>incubator</i>. <i>context</i> specifies the context within which to create the object instance.</p>
<p>If <i>context</i> is 0 (the default), it will create the instance in the engine's <a href="qqmlengine.html#rootContext">root context</a>.</p>
<p><i>forContext</i> specifies a context that this object creation depends upon. If the <i>forContext</i> is being created asynchronously, and the <a href="qqmlincubator.html#IncubationMode-enum">QQmlIncubator::IncubationMode</a> is <a href="qqmlincubator.html#IncubationMode-enum">QQmlIncubator::AsynchronousIfNested</a>, this object will also be created asynchronously. If <i>forContext</i> is 0 (the default), the <i>context</i> will be used for this decision.</p>
<p>The created object and its creation status are available via the <i>incubator</i>.</p>
<p><b>See also </b><a href="qqmlincubator.html">QQmlIncubator</a>.</p>
<!-- @@@create -->
<!-- $$$creationContext[overload1]$$$creationContext -->
<h3 class="fn" id="creationContext"><a name="creationContext"></a><span class="type"><a href="qqmlcontext.html">QQmlContext</a></span> *QQmlComponent::<span class="name">creationContext</span>() const</h3>
<p>Returns the <a href="qqmlcontext.html">QQmlContext</a> the component was created in. This is only valid for components created directly from QML.</p>
<!-- @@@creationContext -->
<!-- $$$engine[overload1]$$$engine -->
<h3 class="fn" id="engine"><a name="engine"></a><span class="type"><a href="qqmlengine.html">QQmlEngine</a></span> *QQmlComponent::<span class="name">engine</span>() const</h3>
<p>Returns the <a href="qqmlengine.html">QQmlEngine</a> of this component.</p>
<p>This function was introduced in  Qt 5.12.</p>
<!-- @@@engine -->
<!-- $$$errors[overload1]$$$errors -->
<h3 class="fn" id="errors"><a name="errors"></a><span class="type">QList</span>&lt;<span class="type"><a href="qqmlerror.html">QQmlError</a></span>&gt; QQmlComponent::<span class="name">errors</span>() const</h3>
<p>Returns the list of errors that occurred during the last compile or create operation. An empty list is returned if <a href="qqmlcomponent.html#isError">isError</a>() is not set.</p>
<!-- @@@errors -->
<!-- $$$isError[overload1]$$$isError -->
<h3 class="fn" id="isError"><a name="isError"></a><span class="type">bool</span> QQmlComponent::<span class="name">isError</span>() const</h3>
<p>Returns true if <a href="qqmlcomponent.html#status-prop">status</a>() == <a href="qqmlcomponent.html#Status-enum">QQmlComponent::Error</a>.</p>
<!-- @@@isError -->
<!-- $$$isLoading[overload1]$$$isLoading -->
<h3 class="fn" id="isLoading"><a name="isLoading"></a><span class="type">bool</span> QQmlComponent::<span class="name">isLoading</span>() const</h3>
<p>Returns true if <a href="qqmlcomponent.html#status-prop">status</a>() == <a href="qqmlcomponent.html#Status-enum">QQmlComponent::Loading</a>.</p>
<!-- @@@isLoading -->
<!-- $$$isNull[overload1]$$$isNull -->
<h3 class="fn" id="isNull"><a name="isNull"></a><span class="type">bool</span> QQmlComponent::<span class="name">isNull</span>() const</h3>
<p>Returns true if <a href="qqmlcomponent.html#status-prop">status</a>() == <a href="qqmlcomponent.html#Status-enum">QQmlComponent::Null</a>.</p>
<!-- @@@isNull -->
<!-- $$$isReady[overload1]$$$isReady -->
<h3 class="fn" id="isReady"><a name="isReady"></a><span class="type">bool</span> QQmlComponent::<span class="name">isReady</span>() const</h3>
<p>Returns true if <a href="qqmlcomponent.html#status-prop">status</a>() == <a href="qqmlcomponent.html#Status-enum">QQmlComponent::Ready</a>.</p>
<!-- @@@isReady -->
<!-- $$$loadUrl[overload1]$$$loadUrlconstQUrl& -->
<h3 class="fn" id="loadUrl"><a name="loadUrl"></a><code>[slot] </code><span class="type">void</span> QQmlComponent::<span class="name">loadUrl</span>(const <span class="type">QUrl</span> &amp;<i>url</i>)</h3>
<p>Load the <a href="qqmlcomponent.html">QQmlComponent</a> from the provided <i>url</i>.</p>
<p>Ensure that the URL provided is full and correct, in particular, use QUrl::fromLocalFile() when loading a file from the local filesystem.</p>
<p>Relative paths will be resolved against <a href="qqmlengine.html#baseUrl">QQmlEngine::baseUrl()</a>, which is the current working directory unless specified.</p>
<!-- @@@loadUrl -->
<!-- $$$loadUrl$$$loadUrlconstQUrl&QQmlComponent::CompilationMode -->
<h3 class="fn" id="loadUrl-1"><a name="loadUrl-1"></a><code>[slot] </code><span class="type">void</span> QQmlComponent::<span class="name">loadUrl</span>(const <span class="type">QUrl</span> &amp;<i>url</i>, <span class="type"><a href="qqmlcomponent.html#CompilationMode-enum">QQmlComponent::CompilationMode</a></span> <i>mode</i>)</h3>
<p>Load the <a href="qqmlcomponent.html">QQmlComponent</a> from the provided <i>url</i>. If <i>mode</i> is <a href="qqmlcomponent.html#CompilationMode-enum">Asynchronous</a>, the component will be loaded and compiled asynchronously.</p>
<p>Ensure that the URL provided is full and correct, in particular, use QUrl::fromLocalFile() when loading a file from the local filesystem.</p>
<p>Relative paths will be resolved against <a href="qqmlengine.html#baseUrl">QQmlEngine::baseUrl()</a>, which is the current working directory unless specified.</p>
<!-- @@@loadUrl -->
<!-- $$$progressChanged -->
<h3 class="fn" id="progressChanged"><a name="progressChanged"></a><code>[signal] </code><span class="type">void</span> QQmlComponent::<span class="name">progressChanged</span>(<span class="type">qreal</span> <i>progress</i>)</h3>
<p>Emitted whenever the component's loading progress changes. <i>progress</i> will be the current progress between 0.0 (nothing loaded) and 1.0 (finished).</p>
<p><b>Note:</b> Notifier signal for property <a href="qqmlcomponent.html#progress-prop">progress</a>. </p><!-- @@@progressChanged -->
<!-- $$$setData[overload1]$$$setDataconstQByteArray&constQUrl& -->
<h3 class="fn" id="setData"><a name="setData"></a><code>[slot] </code><span class="type">void</span> QQmlComponent::<span class="name">setData</span>(const <span class="type">QByteArray</span> &amp;<i>data</i>, const <span class="type">QUrl</span> &amp;<i>url</i>)</h3>
<p>Sets the <a href="qqmlcomponent.html">QQmlComponent</a> to use the given QML <i>data</i>. If <i>url</i> is provided, it is used to set the component name and to provide a base path for items resolved by this component.</p>
<!-- @@@setData -->
<!-- $$$statusChanged -->
<h3 class="fn" id="statusChanged"><a name="statusChanged"></a><code>[signal] </code><span class="type">void</span> QQmlComponent::<span class="name">statusChanged</span>(<span class="type"><a href="qqmlcomponent.html#Status-enum">QQmlComponent::Status</a></span> <i>status</i>)</h3>
<p>Emitted whenever the component's status changes. <i>status</i> will be the new status.</p>
<p><b>Note:</b> Notifier signal for property <a href="qqmlcomponent.html#status-prop">status</a>. </p><!-- @@@statusChanged -->
</div>
        </div>
       </div>
   </div>
   </div>
</div>
<div class="footer">
   <p>
   <acronym title="Copyright">&copy;</acronym> 2019 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>