/usr/share/qt5/doc/qtqml/qqmlcomponent.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 | <?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.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="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">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="#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="#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 <QQmlComponent></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><tr><td class="memItemLeft rightAlign topAlign"> Inherits:</td><td class="memItemRight bottomAlign"> <a href="../qtcore/qobject.html">QObject</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>
<ul>
<li class="fn">1 property inherited from <a href="../qtcore/qobject.html#properties">QObject</a></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> = Q_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 &<i>fileName</i>, QObject *<i>parent</i> = Q_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 &<i>fileName</i>, CompilationMode <i>mode</i>, QObject *<i>parent</i> = Q_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 &<i>url</i>, QObject *<i>parent</i> = Q_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 &<i>url</i>, CompilationMode <i>mode</i>, QObject *<i>parent</i> = Q_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>()</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> = Q_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 &<i>incubator</i>, QQmlContext *<i>context</i> = Q_NULLPTR, QQmlContext *<i>forContext</i> = Q_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"> QList<QQmlError> </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"> 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>
<ul>
<li class="fn">32 public functions inherited from <a href="../qtcore/qobject.html#public-functions">QObject</a></li>
</ul>
<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 &<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 &<i>url</i>, 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 &<i>data</i>, const QUrl &<i>url</i>)</td></tr>
</table></div>
<ul>
<li class="fn">1 public slot inherited from <a href="../qtcore/qobject.html#public-slots">QObject</a></li>
</ul>
<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>
<ul>
<li class="fn">2 signals inherited from <a href="../qtcore/qobject.html#signals">QObject</a></li>
</ul>
<h3>Additional Inherited Members</h3>
<ul>
<li class="fn">1 public variable inherited from <a href="../qtcore/qobject.html#public-variables">QObject</a></li>
<li class="fn">10 static public members inherited from <a href="../qtcore/qobject.html#static-public-members">QObject</a></li>
<li class="fn">9 protected functions inherited from <a href="../qtcore/qobject.html#protected-functions">QObject</a></li>
<li class="fn">2 protected variables inherited from <a href="../qtcore/qobject.html#protected-variables">QObject</a></li>
</ul>
<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">
import QtQuick 2.0
<span class="type">Item</span> {
<span class="name">width</span>: <span class="number">200</span>
<span class="name">height</span>: <span class="number">200</span>
}
</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"><a href="../qtcore/qurl.html">QUrl</a></span><span class="operator">::</span>fromLocalFile(<span class="string">"main.qml"</span>));
<span class="type"><a href="../qtcore/qobject.html#QObject">QObject</a></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"><</span><span class="type">QQuickItem</span><span class="operator">*</span><span class="operator">></span>(myObject);
<span class="type">int</span> width <span class="operator">=</span> item<span class="operator">-</span><span class="operator">></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)->engine();</span>
<span class="type"><a href="qqmlcomponent.html#QQmlComponent">QQmlComponent</a></span> component(engine<span class="operator">,</span> <span class="type"><a href="../qtcore/qurl.html">QUrl</a></span><span class="operator">::</span>fromLocalFile(<span class="string">"MyItem.qml"</span>));
<span class="type">QQuickItem</span> <span class="operator">*</span>childItem <span class="operator">=</span> qobject_cast<span class="operator"><</span><span class="type">QQuickItem</span><span class="operator">*</span><span class="operator">></span>(component<span class="operator">.</span>create());
childItem<span class="operator">-</span><span class="operator">></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 <a href="../qtcore/qobject.html">QObject</a> subclass, as the instance will not yet have a context nor engine.</p>
<a name="network-components"></a>
<h4 >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"><a href="../qtcore/qurl.html">QUrl</a></span>(<span class="string">"http://www.example.com/main.qml"</span>));
<span class="keyword">if</span> (component<span class="operator">-</span><span class="operator">></span>isLoading())
<span class="type"><a href="../qtcore/qobject.html#QObject">QObject</a></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">></span>isError()) {
<a href="../qtcore/qtglobal.html#qWarning">qWarning</a>() <span class="operator"><</span><span class="operator"><</span> component<span class="operator">-</span><span class="operator">></span>errors();
} <span class="keyword">else</span> {
<span class="type"><a href="../qtcore/qobject.html#QObject">QObject</a></span> <span class="operator">*</span>myObject <span class="operator">=</span> component<span class="operator">-</span><span class="operator">></span>create();
}
}
</pre>
<p>Note that the Qt Quick 1 version is named QDeclarativeComponent.</p>
</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"><a href="../qtcore/qtglobal.html#qreal-typedef">qreal</a></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"> 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"><a href="../qtcore/qurl.html">QUrl</a></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"><a href="../qtcore/qobject.html#QObject">QObject</a></span> *<i>parent</i> = Q_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"><a href="../qtcore/qstring.html">QString</a></span> &<i>fileName</i>, <span class="type"><a href="../qtcore/qobject.html#QObject">QObject</a></span> *<i>parent</i> = Q_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&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"><a href="../qtcore/qstring.html">QString</a></span> &<i>fileName</i>, <span class="type"><a href="qqmlcomponent.html#CompilationMode-enum">CompilationMode</a></span> <i>mode</i>, <span class="type"><a href="../qtcore/qobject.html#QObject">QObject</a></span> *<i>parent</i> = Q_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"><a href="../qtcore/qurl.html">QUrl</a></span> &<i>url</i>, <span class="type"><a href="../qtcore/qobject.html#QObject">QObject</a></span> *<i>parent</i> = Q_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 <a href="../qtcore/qurl.html#fromLocalFile">QUrl::fromLocalFile</a>() when loading a file from the local filesystem.</p>
<p>Relative paths will be resolved against the engine's <a href="qqmlengine.html#baseUrl">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&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"><a href="../qtcore/qurl.html">QUrl</a></span> &<i>url</i>, <span class="type"><a href="qqmlcomponent.html#CompilationMode-enum">CompilationMode</a></span> <i>mode</i>, <span class="type"><a href="../qtcore/qobject.html#QObject">QObject</a></span> *<i>parent</i> = Q_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 <a href="../qtcore/qurl.html#fromLocalFile">QUrl::fromLocalFile</a>() when loading a file from the local filesystem.</p>
<p>Relative paths will be resolved against the engine's <a href="qqmlengine.html#baseUrl">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>[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"><a href="../qtcore/qobject.html#QObject">QObject</a></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 0 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"><a href="../qtcore/qobject.html#QObject">QObject</a></span> *QQmlComponent::<span class="name">create</span>(<span class="type"><a href="qqmlcontext.html">QQmlContext</a></span> *<i>context</i> = Q_NULLPTR)</h3>
<p>Create an object instance from this component. Returns 0 if creation failed. <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>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> &<i>incubator</i>, <span class="type"><a href="qqmlcontext.html">QQmlContext</a></span> *<i>context</i> = Q_NULLPTR, <span class="type"><a href="qqmlcontext.html">QQmlContext</a></span> *<i>forContext</i> = Q_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 -->
<!-- $$$errors[overload1]$$$errors -->
<h3 class="fn" id="errors"><a name="errors"></a><span class="type"><a href="../qtcore/qlist.html">QList</a></span><<span class="type"><a href="qqmlerror.html">QQmlError</a></span>> 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"><a href="../qtcore/qurl.html">QUrl</a></span> &<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 <a href="../qtcore/qurl.html#fromLocalFile">QUrl::fromLocalFile</a>() when loading a file from the local filesystem.</p>
<p>Relative paths will be resolved against the engine's <a href="qqmlengine.html#baseUrl">baseUrl()</a>, which is the current working directory unless specified.</p>
<!-- @@@loadUrl -->
<!-- $$$loadUrl$$$loadUrlconstQUrl&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"><a href="../qtcore/qurl.html">QUrl</a></span> &<i>url</i>, <span class="type"><a href="qqmlcomponent.html#CompilationMode-enum">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 <a href="../qtcore/qurl.html#fromLocalFile">QUrl::fromLocalFile</a>() when loading a file from the local filesystem.</p>
<p>Relative paths will be resolved against the engine's <a href="qqmlengine.html#baseUrl">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"><a href="../qtcore/qtglobal.html#qreal-typedef">qreal</a></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"><a href="../qtcore/qbytearray.html">QByteArray</a></span> &<i>data</i>, const <span class="type"><a href="../qtcore/qurl.html">QUrl</a></span> &<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">©</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>
|