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
|
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en_US" lang="en_US">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- qdeclarativecomponent.cpp -->
<title>Qt 4.8: QDeclarativeComponent Class Reference</title>
<link rel="stylesheet" type="text/css" href="style/offline.css" />
</head>
<body>
<div class="header" id="qtdocheader">
<div class="content">
<a href="index.html" class="qtref"><span>Qt Reference Documentation</span></a>
</div>
<div class="breadcrumb toolblock">
<ul>
<li class="first"><a href="index.html">Home</a></li>
<!-- Breadcrumbs go here -->
<li><a href="modules.html">Modules</a></li>
<li><a href="qtdeclarative.html">QtDeclarative</a></li>
<li>QDeclarativeComponent</li>
</ul>
</div>
</div>
<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="#signals">Signals</a></li>
<li class="level1"><a href="#protected-functions">Protected Functions</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">QDeclarativeComponent Class Reference</h1>
<!-- $$$QDeclarativeComponent-brief -->
<p>The QDeclarativeComponent class encapsulates a QML component definition. <a href="#details">More...</a></p>
<!-- @@@QDeclarativeComponent -->
<pre class="cpp"> <span class="preprocessor">#include <QDeclarativeComponent></span></pre><p><b>Inherits: </b><a href="qobject.html">QObject</a>.</p>
<p>This class was introduced in Qt 4.7.</p>
<ul>
<li><a href="qdeclarativecomponent-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="qdeclarativecomponent.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="qdeclarativecomponent.html#progress-prop">progress</a></b> : const qreal</li>
<li class="fn"><b><a href="qdeclarativecomponent.html#status-prop">status</a></b> : const Status</li>
<li class="fn"><b><a href="qdeclarativecomponent.html#url-prop">url</a></b> : const QUrl</li>
</ul>
<ul>
<li class="fn">1 property inherited from <a href="qobject.html#properties">QObject</a></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="qdeclarativecomponent.html#QDeclarativeComponent">QDeclarativeComponent</a></b> ( QDeclarativeEngine * <i>engine</i>, QObject * <i>parent</i> = 0 )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qdeclarativecomponent.html#QDeclarativeComponent-3">QDeclarativeComponent</a></b> ( QDeclarativeEngine * <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="qdeclarativecomponent.html#QDeclarativeComponent-4">QDeclarativeComponent</a></b> ( QDeclarativeEngine * <i>engine</i>, const QUrl & <i>url</i>, QObject * <i>parent</i> = 0 )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual </td><td class="memItemRight bottomAlign"><b><a href="qdeclarativecomponent.html#dtor.QDeclarativeComponent">~QDeclarativeComponent</a></b> ()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual QObject * </td><td class="memItemRight bottomAlign"><b><a href="qdeclarativecomponent.html#beginCreate">beginCreate</a></b> ( QDeclarativeContext * <i>context</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual void </td><td class="memItemRight bottomAlign"><b><a href="qdeclarativecomponent.html#completeCreate">completeCreate</a></b> ()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual QObject * </td><td class="memItemRight bottomAlign"><b><a href="qdeclarativecomponent.html#create">create</a></b> ( QDeclarativeContext * <i>context</i> = 0 )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QDeclarativeContext * </td><td class="memItemRight bottomAlign"><b><a href="qdeclarativecomponent.html#creationContext">creationContext</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QList<QDeclarativeError> </td><td class="memItemRight bottomAlign"><b><a href="qdeclarativecomponent.html#errors">errors</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qdeclarativecomponent.html#isError">isError</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qdeclarativecomponent.html#isLoading">isLoading</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qdeclarativecomponent.html#isNull">isNull</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qdeclarativecomponent.html#isReady">isReady</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qdeclarativecomponent.html#loadUrl">loadUrl</a></b> ( const QUrl & <i>url</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> qreal </td><td class="memItemRight bottomAlign"><b><a href="qdeclarativecomponent.html#progress-prop">progress</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qdeclarativecomponent.html#setData">setData</a></b> ( const QByteArray & <i>data</i>, const QUrl & <i>url</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> Status </td><td class="memItemRight bottomAlign"><b><a href="qdeclarativecomponent.html#status-prop">status</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QUrl </td><td class="memItemRight bottomAlign"><b><a href="qdeclarativecomponent.html#url-prop">url</a></b> () const</td></tr>
</table>
<ul>
<li class="fn">29 public functions inherited from <a href="qobject.html#public-functions">QObject</a></li>
</ul>
<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="qdeclarativecomponent.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="qdeclarativecomponent.html#statusChanged">statusChanged</a></b> ( QDeclarativeComponent::Status <i>status</i> )</td></tr>
</table>
<ul>
<li class="fn">1 signal inherited from <a href="qobject.html#signals">QObject</a></li>
</ul>
<a name="protected-functions"></a>
<h2>Protected Functions</h2>
<table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qdeclarativecomponent.html#Q_REVISION">Q_REVISION</a></b> ()</td></tr>
</table>
<ul>
<li class="fn">8 protected functions inherited from <a href="qobject.html#protected-functions">QObject</a></li>
</ul>
<h3>Additional Inherited Members</h3>
<ul>
<li class="fn">1 public slot inherited from <a href="qobject.html#public-slots">QObject</a></li>
<li class="fn">7 static public members inherited from <a href="qobject.html#static-public-members">QObject</a></li>
</ul>
<a name="details"></a>
<!-- $$$QDeclarativeComponent-description -->
<div class="descr">
<h2>Detailed Description</h2>
<p>The QDeclarativeComponent class encapsulates a QML component definition.</p>
<p>Components are reusable, encapsulated QML elements with well-defined interfaces. They are often defined in <a href="qdeclarativedocuments.html">Component Files</a>.</p>
<p>A QDeclarativeComponent 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 1.0
<span class="type"><a href="qml-item.html">Item</a></span> {
<span class="name">width</span>: <span class="number">200</span>
<span class="name">height</span>: <span class="number">200</span>
}</pre>
<p>The following code loads this QML file as a component, creates an instance of this component using <a href="qdeclarativecomponent.html#create">create</a>(), and then queries the <a href="qml-item.html">Item</a>'s <a href="qml-item.html#width-prop">width</a> value:</p>
<pre class="cpp"> <span class="type"><a href="qdeclarativeengine.html">QDeclarativeEngine</a></span> <span class="operator">*</span>engine <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qdeclarativeengine.html">QDeclarativeEngine</a></span>;
<span class="type">QDeclarativeComponent</span> component(engine<span class="operator">,</span> <span class="type"><a href="qurl.html">QUrl</a></span><span class="operator">::</span>fromLocalFile(<span class="string">"main.qml"</span>));
<span class="type"><a href="qobject.html">QObject</a></span> <span class="operator">*</span>myObject <span class="operator">=</span> component<span class="operator">.</span><a href="qdeclarativecomponent.html#create">create</a>();
<span class="type"><a href="qdeclarativeitem.html">QDeclarativeItem</a></span> <span class="operator">*</span>item <span class="operator">=</span> qobject_cast<span class="operator"><</span><span class="type"><a href="qdeclarativeitem.html">QDeclarativeItem</a></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 QDeclarativeComponent is a network resource, or if the QML document references a network resource, the QDeclarativeComponent has to fetch the network data before it is able to create objects. In this case, the QDeclarativeComponent will have a <a href="qdeclarativecomponent.html#Status-enum">Loading</a> <a href="qdeclarativecomponent.html#status-prop">status</a>. An application will have to wait until the component is <a href="qdeclarativecomponent.html#Status-enum">Ready</a> before calling <a href="qdeclarativecomponent.html#create">QDeclarativeComponent::create</a>().</p>
<p>The following example shows how to load a QML file from a network resource. After creating the QDeclarativeComponent, it tests whether the component is loading. If it is, it connects to the <a href="qdeclarativecomponent.html#statusChanged">QDeclarativeComponent::statusChanged</a>() signal and otherwise calls the <tt>continueLoading()</tt> method directly. Note that <a href="qdeclarativecomponent.html#isLoading">QDeclarativeComponent::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">QDeclarativeComponent</span>(engine<span class="operator">,</span> <span class="type"><a href="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="qobject.html">QObject</a></span><span class="operator">::</span>connect(component<span class="operator">,</span> SIGNAL(statusChanged(<span class="type">QDeclarativeComponent</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="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="qobject.html">QObject</a></span> <span class="operator">*</span>myObject <span class="operator">=</span> component<span class="operator">-</span><span class="operator">></span>create();
}
}</pre>
</div>
<p><b>See also </b><a href="qtbinding.html">Using QML Bindings in C++ Applications</a> and <a href="qml-integration.html">Integrating QML Code with Existing Qt UI Code</a>.</p>
<!-- @@@QDeclarativeComponent -->
<div class="types">
<h2>Member Type Documentation</h2>
<!-- $$$Status$$$Null$$$Ready$$$Loading$$$Error -->
<h3 class="fn"><a name="Status-enum"></a>enum QDeclarativeComponent::<span class="name">Status</span></h3>
<p>Specifies the loading status of the <a href="qdeclarativecomponent.html">QDeclarativeComponent</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>QDeclarativeComponent::Null</tt></td><td class="topAlign"><tt>0</tt></td><td class="topAlign">This <a href="qdeclarativecomponent.html">QDeclarativeComponent</a> has no data. Call <a href="qdeclarativecomponent.html#loadUrl">loadUrl</a>() or <a href="qdeclarativecomponent.html#setData">setData</a>() to add QML content.</td></tr>
<tr><td class="topAlign"><tt>QDeclarativeComponent::Ready</tt></td><td class="topAlign"><tt>1</tt></td><td class="topAlign">This <a href="qdeclarativecomponent.html">QDeclarativeComponent</a> is ready and <a href="qdeclarativecomponent.html#create">create</a>() may be called.</td></tr>
<tr><td class="topAlign"><tt>QDeclarativeComponent::Loading</tt></td><td class="topAlign"><tt>2</tt></td><td class="topAlign">This <a href="qdeclarativecomponent.html">QDeclarativeComponent</a> is loading network data.</td></tr>
<tr><td class="topAlign"><tt>QDeclarativeComponent::Error</tt></td><td class="topAlign"><tt>3</tt></td><td class="topAlign">An error has occurred. Call <a href="qdeclarativecomponent.html#errors">errors</a>() to retrieve a list of {<a href="qdeclarativeerror.html">QDeclarativeError</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"><a href="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>
<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><a href="qdeclarativecomponent.html#progressChanged">progressChanged</a></b></span> ( qreal <i>progress</i> )</td></tr>
</table>
<!-- @@@progress -->
<!-- $$$status-prop$$$status$$$statusChangedQDeclarativeComponent::Status -->
<h3 class="fn"><a name="status-prop"></a><span class="name">status</span> : const <span class="type"><a href="qdeclarativecomponent.html#Status-enum">Status</a></span></h3>
<p>The component's current <a href="qdeclarativecomponent.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><a href="qdeclarativecomponent.html#statusChanged">statusChanged</a></b></span> ( QDeclarativeComponent::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"><a href="qurl.html">QUrl</a></span></h3>
<p>The component URL. This is the URL passed to either the constructor, or the <a href="qdeclarativecomponent.html#loadUrl">loadUrl</a>() or <a href="qdeclarativecomponent.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>
<!-- $$$QDeclarativeComponent[overload1]$$$QDeclarativeComponentQDeclarativeEngine*QObject* -->
<h3 class="fn"><a name="QDeclarativeComponent"></a>QDeclarativeComponent::<span class="name">QDeclarativeComponent</span> ( <span class="type"><a href="qdeclarativeengine.html">QDeclarativeEngine</a></span> * <i>engine</i>, <span class="type"><a href="qobject.html">QObject</a></span> * <i>parent</i> = 0 )</h3>
<p>Create a <a href="qdeclarativecomponent.html">QDeclarativeComponent</a> with no data and give it the specified <i>engine</i> and <i>parent</i>. Set the data with <a href="qdeclarativecomponent.html#setData">setData</a>().</p>
<!-- @@@QDeclarativeComponent -->
<!-- $$$QDeclarativeComponent$$$QDeclarativeComponentQDeclarativeEngine*constQString&QObject* -->
<h3 class="fn"><a name="QDeclarativeComponent-3"></a>QDeclarativeComponent::<span class="name">QDeclarativeComponent</span> ( <span class="type"><a href="qdeclarativeengine.html">QDeclarativeEngine</a></span> * <i>engine</i>, const <span class="type"><a href="qstring.html">QString</a></span> & <i>fileName</i>, <span class="type"><a href="qobject.html">QObject</a></span> * <i>parent</i> = 0 )</h3>
<p>Create a <a href="qdeclarativecomponent.html">QDeclarativeComponent</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="qdeclarativecomponent.html#loadUrl">loadUrl</a>().</p>
<!-- @@@QDeclarativeComponent -->
<!-- $$$QDeclarativeComponent$$$QDeclarativeComponentQDeclarativeEngine*constQUrl&QObject* -->
<h3 class="fn"><a name="QDeclarativeComponent-4"></a>QDeclarativeComponent::<span class="name">QDeclarativeComponent</span> ( <span class="type"><a href="qdeclarativeengine.html">QDeclarativeEngine</a></span> * <i>engine</i>, const <span class="type"><a href="qurl.html">QUrl</a></span> & <i>url</i>, <span class="type"><a href="qobject.html">QObject</a></span> * <i>parent</i> = 0 )</h3>
<p>Create a <a href="qdeclarativecomponent.html">QDeclarativeComponent</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="qurl.html#fromLocalFile">QUrl::fromLocalFile</a>() when loading a file from the local filesystem.</p>
<p><b>See also </b><a href="qdeclarativecomponent.html#loadUrl">loadUrl</a>().</p>
<!-- @@@QDeclarativeComponent -->
<!-- $$$~QDeclarativeComponent[overload1]$$$~QDeclarativeComponent -->
<h3 class="fn"><a name="dtor.QDeclarativeComponent"></a>QDeclarativeComponent::<span class="name">~QDeclarativeComponent</span> ()<tt> [virtual]</tt></h3>
<p>Destruct the <a href="qdeclarativecomponent.html">QDeclarativeComponent</a>.</p>
<!-- @@@~QDeclarativeComponent -->
<!-- $$$Q_REVISION[overload1]$$$Q_REVISION -->
<h3 class="fn"><a name="Q_REVISION"></a>QDeclarativeComponent::<span class="name">Q_REVISION</span> ()<tt> [protected]</tt></h3>
<!-- @@@Q_REVISION -->
<!-- $$$beginCreate[overload1]$$$beginCreateQDeclarativeContext* -->
<h3 class="fn"><a name="beginCreate"></a><span class="type"><a href="qobject.html">QObject</a></span> * QDeclarativeComponent::<span class="name">beginCreate</span> ( <span class="type"><a href="qdeclarativecontext.html">QDeclarativeContext</a></span> * <i>context</i> )<tt> [virtual]</tt></h3>
<p>This method provides more advanced control over component instance creation. In general, programmers should use <a href="qdeclarativecomponent.html#create">QDeclarativeComponent::create</a>() to create a component.</p>
<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>When <a href="qdeclarativecomponent.html">QDeclarativeComponent</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 the first time.</li>
<li>If applicable, <a href="qdeclarativeparserstatus.html#componentComplete">QDeclarativeParserStatus::componentComplete</a>() is called on objects.</li>
</ol>
<p>QDeclarativeComponent::beginCreate() differs from <a href="qdeclarativecomponent.html#create">QDeclarativeComponent::create</a>() in that it only performs step 1. <a href="qdeclarativecomponent.html#completeCreate">QDeclarativeComponent::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>
<!-- @@@beginCreate -->
<!-- $$$completeCreate[overload1]$$$completeCreate -->
<h3 class="fn"><a name="completeCreate"></a><span class="type">void</span> QDeclarativeComponent::<span class="name">completeCreate</span> ()<tt> [virtual]</tt></h3>
<p>This method provides more advanced control over component instance creation. In general, programmers should use <a href="qdeclarativecomponent.html#create">QDeclarativeComponent::create</a>() to create a component.</p>
<p>Complete a component creation begin with <a href="qdeclarativecomponent.html#beginCreate">QDeclarativeComponent::beginCreate</a>().</p>
<!-- @@@completeCreate -->
<!-- $$$create[overload1]$$$createQDeclarativeContext* -->
<h3 class="fn"><a name="create"></a><span class="type"><a href="qobject.html">QObject</a></span> * QDeclarativeComponent::<span class="name">create</span> ( <span class="type"><a href="qdeclarativecontext.html">QDeclarativeContext</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="qdeclarativeengine.html#rootContext">root context</a>.</p>
<!-- @@@create -->
<!-- $$$creationContext[overload1]$$$creationContext -->
<h3 class="fn"><a name="creationContext"></a><span class="type"><a href="qdeclarativecontext.html">QDeclarativeContext</a></span> * QDeclarativeComponent::<span class="name">creationContext</span> () const</h3>
<p>Returns the <a href="qdeclarativecontext.html">QDeclarativeContext</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"><a href="qlist.html">QList</a></span><<span class="type"><a href="qdeclarativeerror.html">QDeclarativeError</a></span>> QDeclarativeComponent::<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="qdeclarativecomponent.html#isError">isError</a>() is not set.</p>
<!-- @@@errors -->
<!-- $$$isError[overload1]$$$isError -->
<h3 class="fn"><a name="isError"></a><span class="type">bool</span> QDeclarativeComponent::<span class="name">isError</span> () const</h3>
<p>Returns true if <a href="qdeclarativecomponent.html#status-prop">status</a>() == <a href="qdeclarativecomponent.html#Status-enum">QDeclarativeComponent::Error</a>.</p>
<!-- @@@isError -->
<!-- $$$isLoading[overload1]$$$isLoading -->
<h3 class="fn"><a name="isLoading"></a><span class="type">bool</span> QDeclarativeComponent::<span class="name">isLoading</span> () const</h3>
<p>Returns true if <a href="qdeclarativecomponent.html#status-prop">status</a>() == <a href="qdeclarativecomponent.html#Status-enum">QDeclarativeComponent::Loading</a>.</p>
<!-- @@@isLoading -->
<!-- $$$isNull[overload1]$$$isNull -->
<h3 class="fn"><a name="isNull"></a><span class="type">bool</span> QDeclarativeComponent::<span class="name">isNull</span> () const</h3>
<p>Returns true if <a href="qdeclarativecomponent.html#status-prop">status</a>() == <a href="qdeclarativecomponent.html#Status-enum">QDeclarativeComponent::Null</a>.</p>
<!-- @@@isNull -->
<!-- $$$isReady[overload1]$$$isReady -->
<h3 class="fn"><a name="isReady"></a><span class="type">bool</span> QDeclarativeComponent::<span class="name">isReady</span> () const</h3>
<p>Returns true if <a href="qdeclarativecomponent.html#status-prop">status</a>() == <a href="qdeclarativecomponent.html#Status-enum">QDeclarativeComponent::Ready</a>.</p>
<!-- @@@isReady -->
<!-- $$$loadUrl[overload1]$$$loadUrlconstQUrl& -->
<h3 class="fn"><a name="loadUrl"></a><span class="type">void</span> QDeclarativeComponent::<span class="name">loadUrl</span> ( const <span class="type"><a href="qurl.html">QUrl</a></span> & <i>url</i> )</h3>
<p>Load the <a href="qdeclarativecomponent.html">QDeclarativeComponent</a> from the provided <i>url</i>.</p>
<p>Ensure that the URL provided is full and correct, in particular, use <a href="qurl.html#fromLocalFile">QUrl::fromLocalFile</a>() when loading a file from the local filesystem.</p>
<!-- @@@loadUrl -->
<!-- $$$progressChanged[overload1]$$$progressChangedqreal -->
<h3 class="fn"><a name="progressChanged"></a><span class="type">void</span> QDeclarativeComponent::<span class="name">progressChanged</span> ( <span class="type"><a href="qtglobal.html#qreal-typedef">qreal</a></span> <i>progress</i> )<tt> [signal]</tt></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>
<!-- @@@progressChanged -->
<!-- $$$setData[overload1]$$$setDataconstQByteArray&constQUrl& -->
<h3 class="fn"><a name="setData"></a><span class="type">void</span> QDeclarativeComponent::<span class="name">setData</span> ( const <span class="type"><a href="qbytearray.html">QByteArray</a></span> & <i>data</i>, const <span class="type"><a href="qurl.html">QUrl</a></span> & <i>url</i> )</h3>
<p>Sets the <a href="qdeclarativecomponent.html">QDeclarativeComponent</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[overload1]$$$statusChangedQDeclarativeComponent::Status -->
<h3 class="fn"><a name="statusChanged"></a><span class="type">void</span> QDeclarativeComponent::<span class="name">statusChanged</span> ( <span class="type"><a href="qdeclarativecomponent.html#Status-enum">QDeclarativeComponent::Status</a></span> <i>status</i> )<tt> [signal]</tt></h3>
<p>Emitted whenever the component's status changes. <i>status</i> will be the new status.</p>
<!-- @@@statusChanged -->
</div>
<div class="ft">
<span></span>
</div>
</div>
<div class="footer">
<p>
<acronym title="Copyright">©</acronym> 2012 Nokia Corporation and/or its
subsidiaries. Documentation contributions included herein are the copyrights of
their respective owners.</p>
<br />
<p>
The documentation provided herein is licensed under the terms of the
<a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation
License version 1.3</a> as published by the Free Software Foundation.</p>
<p>
Documentation sources may be obtained from <a href="http://www.qt-project.org">
www.qt-project.org</a>.</p>
<br />
<p>
Nokia, Qt and their respective logos are trademarks of Nokia Corporation
in Finland and/or other countries worldwide. All other trademarks are property
of their respective owners. <a title="Privacy Policy"
href="http://en.gitorious.org/privacy_policy/">Privacy Policy</a></p>
</div>
</body>
</html>
|