/usr/share/qt5/doc/qtqml/qqmlcomponent.html is in qtdeclarative5-doc-html 5.2.1-3ubuntu15.
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 | <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.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" />
<!-- qqmlcomponent.cpp -->
<title>QQmlComponent Class | QtQml 5.2</title>
<link rel="stylesheet" type="text/css" href="style/offline.css" />
</head>
<body>
<div class="header" id="qtdocheader">
<div class="main">
<div class="main-rounded">
<div class="navigationbar">
<ul>
<li>Qt 5.2</li>
<li><a href="qtqml-index.html">Qt QML</a></li>
<li><a href="qtqml-module.html">C++ Classes</a></li>
<li>QQmlComponent</li>
<li id="buildversion">
Qt 5.2.1 Reference Documentation</li>
</ul>
</div>
</div>
<div class="content">
<div class="line">
<div class="content mainContent">
<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>
<h1 class="title">QQmlComponent Class</h1>
<!-- $$$QQmlComponent-brief -->
<p>The QQmlComponent class encapsulates a QML component definition <a href="#details">More...</a></p>
<!-- @@@QQmlComponent -->
<table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> Header:</td><td class="memItemRight bottomAlign"> </b><tt><span class="preprocessor">#include <QQmlComponent></span>
</tt></td></tr><tr><td class="memItemLeft rightAlign topAlign"> qmake:</td><td class="memItemRight bottomAlign"> <tt>QT += qml</tt></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><ul>
<li><a href="qqmlcomponent-members.html">List of all members, including inherited members</a></li>
</ul>
<a name="public-types"></a>
<h2>Public Types</h2>
<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>
<a name="properties"></a>
<h2>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>Public Functions</h2>
<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> = 0)</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>, QObject *<i> parent</i> = 0)</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 QString &<i> fileName</i>, CompilationMode<i> mode</i>, QObject *<i> parent</i> = 0)</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>, QObject *<i> parent</i> = 0)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qqmlcomponent.html#QQmlComponent-6">QQmlComponent</a></b>(QQmlEngine *<i> engine</i>, const QUrl &<i> url</i>, CompilationMode<i> mode</i>, QObject *<i> parent</i> = 0)</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> = 0)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qqmlcomponent.html#create-2">create</a></b>(QQmlIncubator &<i> incubator</i>, QQmlContext *<i> context</i> = 0, QQmlContext *<i> forContext</i> = 0)</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>
<a name="public-slots"></a>
<h2>Public Slots</h2>
<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-2">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>
<a name="signals"></a>
<h2>Signals</h2>
<table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qqmlcomponent.html#progress-prop">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#status-prop">statusChanged</a></b>(QQmlComponent::Status<i> status</i>)</td></tr>
</table>
<a name="details"></a>
<!-- $$$QQmlComponent-description -->
<div class="descr">
<h2>Detailed Description</h2>
<p>The QQmlComponent class encapsulates a QML component definition</p>
<p>Components are reusable, encapsulated QML types with well-defined interfaces.</p>
<p>A QQmlComponent instance can be created from a QML file. For example, if there is a <tt>main.qml</tt> 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">QQmlComponent</span> component(engine<span class="operator">,</span> <span class="type">QUrl</span><span class="operator">::</span>fromLocalFile(<span class="string">"main.qml"</span>));
<span class="type">QObject</span> <span class="operator">*</span>myObject <span class="operator">=</span> component<span class="operator">.</span><a href="qqmlcomponent.html#create">create</a>();
<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>
<a name="network-components"></a>
<h4>Network Components</h4>
<p>If the URL passed to QQmlComponent is a network resource, or if the QML document references a network resource, the QQmlComponent has to fetch the network data before it is able to create objects. In this case, the QQmlComponent 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 QQmlComponent, it tests whether the component is loading. If it is, it connects to the <a href="qqmlcomponent.html#status-prop">QQmlComponent::statusChanged</a>() signal and otherwise calls the <tt>continueLoading()</tt> 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">QQmlComponent</span>(engine<span class="operator">,</span> <span class="type">QUrl</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">QObject</span><span class="operator">::</span>connect(component<span class="operator">,</span> SIGNAL(statusChanged(<span class="type">QQmlComponent</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()) {
qWarning() <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">QObject</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"><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>
<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"><tt>QQmlComponent::PreferSynchronous</tt></td><td class="topAlign"><tt>0</tt></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"><tt>QQmlComponent::Asynchronous</tt></td><td class="topAlign"><tt>1</tt></td><td class="topAlign">Load/compile the component in a background thread.</td></tr>
</table>
<!-- @@@CompilationMode -->
<!-- $$$Status$$$Null$$$Ready$$$Loading$$$Error -->
<h3 class="fn"><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>
<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"><tt>QQmlComponent::Null</tt></td><td class="topAlign"><tt>0</tt></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"><tt>QQmlComponent::Ready</tt></td><td class="topAlign"><tt>1</tt></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"><tt>QQmlComponent::Loading</tt></td><td class="topAlign"><tt>2</tt></td><td class="topAlign">This <a href="qqmlcomponent.html">QQmlComponent</a> is loading network data.</td></tr>
<tr><td class="topAlign"><tt>QQmlComponent::Error</tt></td><td class="topAlign"><tt>3</tt></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">QQmlError</a>}{errors}.</td></tr>
</table>
<!-- @@@Status -->
</div>
<div class="prop">
<h2>Property Documentation</h2>
<!-- $$$progress-prop$$$progress$$$progressChangedqreal -->
<h3 class="fn"><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>
<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>
<p><b>Notifier signal:</b></p>
<table class="alignedsummary">
<tr><td class="memItemLeft topAlign rightAlign"> void </td><td class="memItemRight bottomAlign"><span class="name"><b>progressChanged</b></span>(qreal<i> progress</i>)</td></tr>
</table>
<!-- @@@progress -->
<!-- $$$status-prop$$$status$$$statusChangedQQmlComponent::Status -->
<h3 class="fn"><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>
<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>
<p><b>Notifier signal:</b></p>
<table class="alignedsummary">
<tr><td class="memItemLeft topAlign rightAlign"> void </td><td class="memItemRight bottomAlign"><span class="name"><b>statusChanged</b></span>(QQmlComponent::Status<i> status</i>)</td></tr>
</table>
<!-- @@@status -->
<!-- $$$url-prop$$$url -->
<h3 class="fn"><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>
<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>
<!-- @@@url -->
</div>
<div class="func">
<h2>Member Function Documentation</h2>
<!-- $$$QQmlComponent[overload1]$$$QQmlComponentQQmlEngine*QObject* -->
<h3 class="fn"><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> = 0)</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"><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> &<i> fileName</i>, <span class="type">QObject</span> *<i> parent</i> = 0)</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"><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">QString</span> &<i> fileName</i>, <span class="type"><a href="qqmlcomponent.html#CompilationMode-enum">CompilationMode</a></span><i> mode</i>, <span class="type">QObject</span> *<i> parent</i> = 0)</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"><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> &<i> url</i>, <span class="type">QObject</span> *<i> parent</i> = 0)</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><b>See also </b><a href="qqmlcomponent.html#loadUrl">loadUrl</a>().</p>
<!-- @@@QQmlComponent -->
<!-- $$$QQmlComponent$$$QQmlComponentQQmlEngine*constQUrl&CompilationModeQObject* -->
<h3 class="fn"><a name="QQmlComponent-6"></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> &<i> url</i>, <span class="type"><a href="qqmlcomponent.html#CompilationMode-enum">CompilationMode</a></span><i> mode</i>, <span class="type">QObject</span> *<i> parent</i> = 0)</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><b>See also </b><a href="qqmlcomponent.html#loadUrl">loadUrl</a>().</p>
<!-- @@@QQmlComponent -->
<!-- $$$~QQmlComponent[overload1]$$$~QQmlComponent -->
<h3 class="fn"><a name="dtor.QQmlComponent"></a>QQmlComponent::<span class="name">~QQmlComponent</span>()<tt> [virtual]</tt></h3>
<p>Destruct the <a href="qqmlcomponent.html">QQmlComponent</a>.</p>
<!-- @@@~QQmlComponent -->
<!-- $$$beginCreate[overload1]$$$beginCreateQQmlContext* -->
<h3 class="fn"><a name="beginCreate"></a><span class="type">QObject</span> * QQmlComponent::<span class="name">beginCreate</span>(<span class="type"><a href="qqmlcontext.html">QQmlContext</a></span> *<i> publicContext</i>)<tt> [virtual]</tt></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>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">
<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"><a name="completeCreate"></a><span class="type">void</span> QQmlComponent::<span class="name">completeCreate</span>()<tt> [virtual]</tt></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"><a name="create"></a><span class="type">QObject</span> * QQmlComponent::<span class="name">create</span>(<span class="type"><a href="qqmlcontext.html">QQmlContext</a></span> *<i> context</i> = 0)<tt> [virtual]</tt></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><b>See also </b><a href="qqmlengine.html#ObjectOwnership-enum">QQmlEngine::ObjectOwnership</a>.</p>
<!-- @@@create -->
<!-- $$$create$$$createQQmlIncubator&QQmlContext*QQmlContext* -->
<h3 class="fn"><a name="create-2"></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> = 0, <span class="type"><a href="qqmlcontext.html">QQmlContext</a></span> *<i> forContext</i> = 0)</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"><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"><a name="errors"></a><span class="type">QList</span><<span class="type"><a href="qqmlerror.html">QQmlError</a></span>> QQmlComponent::<span class="name">errors</span>() const</h3>
<p>Return 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"><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"><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"><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"><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"><a name="loadUrl"></a><span class="type">void</span> QQmlComponent::<span class="name">loadUrl</span>(const <span class="type">QUrl</span> &<i> url</i>)<tt> [slot]</tt></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>
<!-- @@@loadUrl -->
<!-- $$$loadUrl$$$loadUrlconstQUrl&CompilationMode -->
<h3 class="fn"><a name="loadUrl-2"></a><span class="type">void</span> QQmlComponent::<span class="name">loadUrl</span>(const <span class="type">QUrl</span> &<i> url</i>, <span class="type"><a href="qqmlcomponent.html#CompilationMode-enum">CompilationMode</a></span><i> mode</i>)<tt> [slot]</tt></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>
<!-- @@@loadUrl -->
<!-- $$$setData[overload1]$$$setDataconstQByteArray&constQUrl& -->
<h3 class="fn"><a name="setData"></a><span class="type">void</span> QQmlComponent::<span class="name">setData</span>(const <span class="type">QByteArray</span> &<i> data</i>, const <span class="type">QUrl</span> &<i> url</i>)<tt> [slot]</tt></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 -->
</div>
</div>
</div>
</div>
</div>
</div>
<div class="footer">
<p>
<acronym title="Copyright">©</acronym> 2013 Digia Plc and/or its
subsidiaries. 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> Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide. All other trademarks are property
of their respective owners. </p>
</div>
</body>
</html>
|