/usr/share/qt5/doc/qtqml/qqmlengine.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 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 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 | <?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" />
<!-- qqmlengine.cpp -->
<title>QQmlEngine 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>QQmlEngine</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="#signals">Signals</a></li>
<li class="level1"><a href="#static-public-members">Static Public Members</a></li>
<li class="level1"><a href="#protected-functions">Protected Functions</a></li>
<li class="level1"><a href="#related-non-members">Related Non-Members</a></li>
<li class="level1"><a href="#macros">Macros</a></li>
<li class="level1"><a href="#details">Detailed Description</a></li>
</ul>
</div>
<h1 class="title">QQmlEngine Class</h1>
<!-- $$$QQmlEngine-brief -->
<p>The QQmlEngine class provides an environment for instantiating QML components. <a href="#details">More...</a></p>
<!-- @@@QQmlEngine -->
<table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> Header:</td><td class="memItemRight bottomAlign"> </b><tt><span class="preprocessor">#include <QQmlEngine></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"> Inherits:</td><td class="memItemRight bottomAlign"> <a href="qjsengine.html">QJSEngine</a>.</td></tr><tr><td class="memItemLeft rightAlign topAlign"> Inherited By:</td><td class="memItemRight bottomAlign"> <p><a href="qqmlapplicationengine.html">QQmlApplicationEngine</a>.</p>
</td></tr></table><ul>
<li><a href="qqmlengine-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="qqmlengine.html#ObjectOwnership-enum">ObjectOwnership</a></b> { CppOwnership, JavaScriptOwnership }</td></tr>
</table>
<a name="properties"></a>
<h2>Properties</h2>
<ul>
<li class="fn"><b><a href="qqmlengine.html#offlineStoragePath-prop">offlineStoragePath</a></b> : QString</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="qqmlengine.html#QQmlEngine">QQmlEngine</a></b>(QObject *<i> parent</i> = 0)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual </td><td class="memItemRight bottomAlign"><b><a href="qqmlengine.html#dtor.QQmlEngine">~QQmlEngine</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qqmlengine.html#addImageProvider">addImageProvider</a></b>(const QString &<i> providerId</i>, QQmlImageProviderBase *<i> provider</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qqmlengine.html#addImportPath">addImportPath</a></b>(const QString &<i> path</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qqmlengine.html#addNamedBundle">addNamedBundle</a></b>(const QString &<i> name</i>, const QString &<i> fileName</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qqmlengine.html#addPluginPath">addPluginPath</a></b>(const QString &<i> path</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QUrl </td><td class="memItemRight bottomAlign"><b><a href="qqmlengine.html#baseUrl">baseUrl</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qqmlengine.html#clearComponentCache">clearComponentCache</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QQmlImageProviderBase * </td><td class="memItemRight bottomAlign"><b><a href="qqmlengine.html#imageProvider">imageProvider</a></b>(const QString &<i> providerId</i>) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QStringList </td><td class="memItemRight bottomAlign"><b><a href="qqmlengine.html#importPathList">importPathList</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qqmlengine.html#importPlugin">importPlugin</a></b>(const QString &<i> filePath</i>, const QString &<i> uri</i>, QList<QQmlError> *<i> errors</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QQmlIncubationController * </td><td class="memItemRight bottomAlign"><b><a href="qqmlengine.html#incubationController">incubationController</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QNetworkAccessManager * </td><td class="memItemRight bottomAlign"><b><a href="qqmlengine.html#networkAccessManager">networkAccessManager</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QQmlNetworkAccessManagerFactory * </td><td class="memItemRight bottomAlign"><b><a href="qqmlengine.html#networkAccessManagerFactory">networkAccessManagerFactory</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QString </td><td class="memItemRight bottomAlign"><b><a href="qqmlengine.html#offlineStoragePath-prop">offlineStoragePath</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qqmlengine.html#outputWarningsToStandardError">outputWarningsToStandardError</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QStringList </td><td class="memItemRight bottomAlign"><b><a href="qqmlengine.html#pluginPathList">pluginPathList</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qqmlengine.html#removeImageProvider">removeImageProvider</a></b>(const QString &<i> providerId</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QQmlContext * </td><td class="memItemRight bottomAlign"><b><a href="qqmlengine.html#rootContext">rootContext</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qqmlengine.html#setBaseUrl">setBaseUrl</a></b>(const QUrl &<i> url</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qqmlengine.html#setImportPathList">setImportPathList</a></b>(const QStringList &<i> paths</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qqmlengine.html#setIncubationController">setIncubationController</a></b>(QQmlIncubationController *<i> controller</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qqmlengine.html#setNetworkAccessManagerFactory">setNetworkAccessManagerFactory</a></b>(QQmlNetworkAccessManagerFactory *<i> factory</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qqmlengine.html#offlineStoragePath-prop">setOfflineStoragePath</a></b>(const QString &<i> dir</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qqmlengine.html#setOutputWarningsToStandardError">setOutputWarningsToStandardError</a></b>(bool<i> enabled</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qqmlengine.html#setPluginPathList">setPluginPathList</a></b>(const QStringList &<i> paths</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qqmlengine.html#trimComponentCache">trimComponentCache</a></b>()</td></tr>
</table>
<ul>
<li class="fn">8 public functions inherited from <a href="qjsengine.html#public-functions">QJSEngine</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="qqmlengine.html#quit">quit</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qqmlengine.html#warnings">warnings</a></b>(const QList<QQmlError> &<i> warnings</i>)</td></tr>
</table>
<a name="static-public-members"></a>
<h2>Static Public Members</h2>
<table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> QQmlContext * </td><td class="memItemRight bottomAlign"><b><a href="qqmlengine.html#contextForObject">contextForObject</a></b>(const QObject *<i> object</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> ObjectOwnership </td><td class="memItemRight bottomAlign"><b><a href="qqmlengine.html#objectOwnership">objectOwnership</a></b>(QObject *<i> object</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qqmlengine.html#setContextForObject">setContextForObject</a></b>(QObject *<i> object</i>, QQmlContext *<i> context</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qqmlengine.html#setObjectOwnership">setObjectOwnership</a></b>(QObject *<i> object</i>, ObjectOwnership<i> ownership</i>)</td></tr>
</table>
<a name="protected-functions"></a>
<h2>Protected Functions</h2>
<table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> virtual bool </td><td class="memItemRight bottomAlign"><b><a href="qqmlengine.html#event">event</a></b>(QEvent *)</td></tr>
</table>
<a name="related-non-members"></a>
<h2>Related Non-Members</h2>
<table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> QObject * </td><td class="memItemRight bottomAlign"><b><a href="qqmlengine.html#qmlAttachedPropertiesObject">qmlAttachedPropertiesObject</a></b>(const QObject *<i> attachee</i>, bool<i> create</i> = true)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qqmlengine.html#qmlClearTypeRegistrations">qmlClearTypeRegistrations</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qqmlengine.html#qmlProtectModule">qmlProtectModule</a></b>(const char *<i> uri</i>, int<i> majVersion</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qqmlengine.html#qmlRegisterInterface">qmlRegisterInterface</a></b>(const char *<i> typeName</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qqmlengine.html#qmlRegisterRevision">qmlRegisterRevision</a></b>(const char *<i> uri</i>, int<i> versionMajor</i>, int<i> versionMinor</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qqmlengine.html#qmlRegisterSingletonType">qmlRegisterSingletonType</a></b>(const char *<i> uri</i>, int<i> versionMajor</i>, int<i> versionMinor</i>, const char *<i> typeName</i>, QJSValue(* ) ( QQmlEngine *, QJSEngine * )<i> callback</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qqmlengine.html#qmlRegisterSingletonType-2">qmlRegisterSingletonType</a></b>(const char *<i> uri</i>, int<i> versionMajor</i>, int<i> versionMinor</i>, const char *<i> typeName</i>, QObject *(* ) ( QQmlEngine *, QJSEngine * )<i> callback</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qqmlengine.html#qmlRegisterSingletonType-3">qmlRegisterSingletonType</a></b>(const QUrl &<i> url</i>, const char *<i> uri</i>, int<i> versionMajor</i>, int<i> versionMinor</i>, const char *<i> qmlName</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qqmlengine.html#qmlRegisterType">qmlRegisterType</a></b>(const char *<i> uri</i>, int<i> versionMajor</i>, int<i> versionMinor</i>, const char *<i> qmlName</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qqmlengine.html#qmlRegisterType-3">qmlRegisterType</a></b>(const QUrl &<i> url</i>, const char *<i> uri</i>, int<i> versionMajor</i>, int<i> versionMinor</i>, const char *<i> qmlName</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qqmlengine.html#qmlRegisterType-4">qmlRegisterType</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qqmlengine.html#qmlRegisterTypeNotAvailable">qmlRegisterTypeNotAvailable</a></b>(const char *<i> uri</i>, int<i> versionMajor</i>, int<i> versionMinor</i>, const char *<i> qmlName</i>, const QString &<i> message</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qqmlengine.html#qmlRegisterUncreatableType">qmlRegisterUncreatableType</a></b>(const char *<i> uri</i>, int<i> versionMajor</i>, int<i> versionMinor</i>, const char *<i> qmlName</i>, const QString &<i> message</i>)</td></tr>
</table>
<a name="macros"></a>
<h2>Macros</h2>
<table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qqmlengine.html#QML_DECLARE_TYPE">QML_DECLARE_TYPE</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qqmlengine.html#QML_DECLARE_TYPEINFO">QML_DECLARE_TYPEINFO</a></b>(<i> Type</i>, <i> Flags</i>)</td></tr>
</table>
<a name="details"></a>
<!-- $$$QQmlEngine-description -->
<div class="descr">
<h2>Detailed Description</h2>
<p>The QQmlEngine class provides an environment for instantiating QML components.</p>
<p>Each QML component is instantiated in a <a href="qqmlcontext.html">QQmlContext</a>. <a href="qqmlcontext.html">QQmlContext</a>'s are essential for passing data to QML components. In QML, contexts are arranged hierarchically and this hierarchy is managed by the QQmlEngine.</p>
<p>Prior to creating any QML components, an application must have created a QQmlEngine to gain access to a QML context. The following example shows how to create a simple Text item.</p>
<pre class="cpp"><span class="type">QQmlEngine</span> engine;
<span class="type"><a href="qqmlcomponent.html">QQmlComponent</a></span> component(<span class="operator">&</span>engine);
component<span class="operator">.</span>setData(<span class="string">"import QtQuick 2.0\nText { text: \"Hello world!\" }"</span><span class="operator">,</span> <span class="type">QUrl</span>());
<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>(component<span class="operator">.</span>create());
<span class="comment">//add item to view, etc</span>
<span class="operator">.</span><span class="operator">.</span><span class="operator">.</span></pre>
<p>In this case, the Text item will be created in the engine's <a href="qqmlengine.html#rootContext">root context</a>.</p>
<p>Note that the Qt Quick 1 version is called QDeclarativeEngine.</p>
</div>
<p><b>See also </b><a href="qqmlcomponent.html">QQmlComponent</a> and <a href="qqmlcontext.html">QQmlContext</a>.</p>
<!-- @@@QQmlEngine -->
<div class="types">
<h2>Member Type Documentation</h2>
<!-- $$$ObjectOwnership$$$CppOwnership$$$JavaScriptOwnership -->
<h3 class="fn"><a name="ObjectOwnership-enum"></a>enum QQmlEngine::<span class="name">ObjectOwnership</span></h3>
<p>Ownership controls whether or not QML automatically destroys the QObject when the object is garbage collected by the JavaScript engine. The two ownership options are:</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>QQmlEngine::CppOwnership</tt></td><td class="topAlign"><tt>0</tt></td><td class="topAlign">The object is owned by C++ code, and will never be deleted by QML. The JavaScript destroy() method cannot be used on objects with CppOwnership. This option is similar to QScriptEngine::QtOwnership.</td></tr>
<tr><td class="topAlign"><tt>QQmlEngine::JavaScriptOwnership</tt></td><td class="topAlign"><tt>1</tt></td><td class="topAlign">The object is owned by JavaScript. When the object is returned to QML as the return value of a method call or property access, QML will track it, and delete the object if there are no remaining JavaScript references to it and it has no QObject::parent(). An object tracked by one <a href="qqmlengine.html">QQmlEngine</a> will be deleted during that <a href="qqmlengine.html">QQmlEngine</a>'s destructor, and thus JavaScript references between objects with JavaScriptOwnership from two different engines will not be valid after the deletion of one of those engines. This option is similar to QScriptEngine::ScriptOwnership.</td></tr>
</table>
<p>Generally an application doesn't need to set an object's ownership explicitly. QML uses a heuristic to set the default object ownership. By default, an object that is created by QML has JavaScriptOwnership. The exception to this are the root objects created by calling <a href="qqmlcomponent.html#create">QQmlComponent::create</a>() or <a href="qqmlcomponent.html#beginCreate">QQmlComponent::beginCreate</a>() which have CppOwnership by default. The ownership of these root-level objects is considered to have been transferred to the C++ caller.</p>
<p>Objects not-created by QML have CppOwnership by default. The exception to this is objects returned from C++ method calls; in these cases, the ownership of the returned objects will be set to JavaScriptOwnerShip. Note this applies only to explicit invocations of Q_INVOKABLE methods or slots, and not to property getter invocations.</p>
<p>Calling <a href="qqmlengine.html#setObjectOwnership">setObjectOwnership</a>() overrides the default ownership heuristic used by QML.</p>
<!-- @@@ObjectOwnership -->
</div>
<div class="prop">
<h2>Property Documentation</h2>
<!-- $$$offlineStoragePath-prop$$$offlineStoragePath$$$setOfflineStoragePathconstQString& -->
<h3 class="fn"><a name="offlineStoragePath-prop"></a><span class="name">offlineStoragePath</span> : <span class="type">QString</span></h3>
<p>This property holds the directory for storing offline user data.</p>
<p>Returns the directory where SQL and other offline storage is placed.</p>
<p>QQuickWebView and the SQL databases created with openDatabase() are stored here.</p>
<p>The default is QML/OfflineStorage in the platform-standard user application data directory.</p>
<p>Note that the path may not currently exist on the filesystem, so callers wanting to <i>create</i> new files at this location should create it first - see QDir::mkpath().</p>
<p><b>Access functions:</b></p>
<table class="alignedsummary">
<tr><td class="memItemLeft topAlign rightAlign"> QString </td><td class="memItemRight bottomAlign"><span class="name"><b>offlineStoragePath</b></span>() const</td></tr>
<tr><td class="memItemLeft topAlign rightAlign"> void </td><td class="memItemRight bottomAlign"><span class="name"><b>setOfflineStoragePath</b></span>(const QString &<i> dir</i>)</td></tr>
</table>
<!-- @@@offlineStoragePath -->
</div>
<div class="func">
<h2>Member Function Documentation</h2>
<!-- $$$QQmlEngine[overload1]$$$QQmlEngineQObject* -->
<h3 class="fn"><a name="QQmlEngine"></a>QQmlEngine::<span class="name">QQmlEngine</span>(<span class="type">QObject</span> *<i> parent</i> = 0)</h3>
<p>Create a new <a href="qqmlengine.html">QQmlEngine</a> with the given <i>parent</i>.</p>
<!-- @@@QQmlEngine -->
<!-- $$$~QQmlEngine[overload1]$$$~QQmlEngine -->
<h3 class="fn"><a name="dtor.QQmlEngine"></a>QQmlEngine::<span class="name">~QQmlEngine</span>()<tt> [virtual]</tt></h3>
<p>Destroys the <a href="qqmlengine.html">QQmlEngine</a>.</p>
<p>Any <a href="qqmlcontext.html">QQmlContext</a>'s created on this engine will be invalidated, but not destroyed (unless they are parented to the <a href="qqmlengine.html">QQmlEngine</a> object).</p>
<p>See <a href="qjsengine.html">QJSEngine</a> docs for details on cleaning up the JS engine.</p>
<!-- @@@~QQmlEngine -->
<!-- $$$addImageProvider[overload1]$$$addImageProviderconstQString&QQmlImageProviderBase* -->
<h3 class="fn"><a name="addImageProvider"></a><span class="type">void</span> QQmlEngine::<span class="name">addImageProvider</span>(const <span class="type">QString</span> &<i> providerId</i>, <span class="type"><a href="qqmlimageproviderbase.html">QQmlImageProviderBase</a></span> *<i> provider</i>)</h3>
<p>Sets the <i>provider</i> to use for images requested via the <i>image</i>: url scheme, with host <i>providerId</i>. The <a href="qqmlengine.html">QQmlEngine</a> takes ownership of <i>provider</i>.</p>
<p>Image providers enable support for pixmap and threaded image requests. See the QQuickImageProvider documentation for details on implementing and using image providers.</p>
<p>All required image providers should be added to the engine before any QML sources files are loaded.</p>
<p><b>See also </b><a href="qqmlengine.html#removeImageProvider">removeImageProvider</a>(), QQuickImageProvider, and <a href="qqmlimageproviderbase.html">QQmlImageProviderBase</a>.</p>
<!-- @@@addImageProvider -->
<!-- $$$addImportPath[overload1]$$$addImportPathconstQString& -->
<h3 class="fn"><a name="addImportPath"></a><span class="type">void</span> QQmlEngine::<span class="name">addImportPath</span>(const <span class="type">QString</span> &<i> path</i>)</h3>
<p>Adds <i>path</i> as a directory where the engine searches for installed modules in a URL-based directory structure.</p>
<p>The <i>path</i> may be a local filesystem directory, a Qt Resource path (<tt>:/imports</tt>), a Qt Resource url (<tt>qrc:/imports</tt>) or a URL.</p>
<p>The <i>path</i> will be converted into canonical form before it is added to the import path list.</p>
<p>The newly added <i>path</i> will be first in the <a href="qqmlengine.html#importPathList">importPathList</a>().</p>
<p><b>See also </b><a href="qqmlengine.html#setImportPathList">setImportPathList</a>() and <a href="qtqml-modules-topic.html">QML Modules</a>.</p>
<!-- @@@addImportPath -->
<!-- $$$addNamedBundle[overload1]$$$addNamedBundleconstQString&constQString& -->
<h3 class="fn"><a name="addNamedBundle"></a><span class="type">bool</span> QQmlEngine::<span class="name">addNamedBundle</span>(const <span class="type">QString</span> &<i> name</i>, const <span class="type">QString</span> &<i> fileName</i>)</h3>
<!-- @@@addNamedBundle -->
<!-- $$$addPluginPath[overload1]$$$addPluginPathconstQString& -->
<h3 class="fn"><a name="addPluginPath"></a><span class="type">void</span> QQmlEngine::<span class="name">addPluginPath</span>(const <span class="type">QString</span> &<i> path</i>)</h3>
<p>Adds <i>path</i> as a directory where the engine searches for native plugins for imported modules (referenced in the <tt>qmldir</tt> file).</p>
<p>By default, the list contains only <tt>.</tt>, i.e. the engine searches in the directory of the <tt>qmldir</tt> file itself.</p>
<p>The newly added <i>path</i> will be first in the <a href="qqmlengine.html#pluginPathList">pluginPathList</a>().</p>
<p><b>See also </b><a href="qqmlengine.html#setPluginPathList">setPluginPathList</a>().</p>
<!-- @@@addPluginPath -->
<!-- $$$baseUrl[overload1]$$$baseUrl -->
<h3 class="fn"><a name="baseUrl"></a><span class="type">QUrl</span> QQmlEngine::<span class="name">baseUrl</span>() const</h3>
<p>Return the base URL for this engine. The base URL is only used to resolve components when a relative URL is passed to the <a href="qqmlcomponent.html">QQmlComponent</a> constructor.</p>
<p>If a base URL has not been explicitly set, this method returns the application's current working directory.</p>
<p><b>See also </b><a href="qqmlengine.html#setBaseUrl">setBaseUrl</a>().</p>
<!-- @@@baseUrl -->
<!-- $$$clearComponentCache[overload1]$$$clearComponentCache -->
<h3 class="fn"><a name="clearComponentCache"></a><span class="type">void</span> QQmlEngine::<span class="name">clearComponentCache</span>()</h3>
<p>Clears the engine's internal component cache.</p>
<p>This function causes the property metadata of all components previously loaded by the engine to be destroyed. All previously loaded components and the property bindings for all extant objects created from those components will cease to function.</p>
<p>This function returns the engine to a state where it does not contain any loaded component data. This may be useful in order to reload a smaller subset of the previous component set, or to load a new version of a previously loaded component.</p>
<p>Once the component cache has been cleared, components must be loaded before any new objects can be created.</p>
<p><b>See also </b><a href="qqmlengine.html#trimComponentCache">trimComponentCache</a>().</p>
<!-- @@@clearComponentCache -->
<!-- $$$contextForObject[overload1]$$$contextForObjectconstQObject* -->
<h3 class="fn"><a name="contextForObject"></a><span class="type"><a href="qqmlcontext.html">QQmlContext</a></span> * QQmlEngine::<span class="name">contextForObject</span>(const <span class="type">QObject</span> *<i> object</i>)<tt> [static]</tt></h3>
<p>Returns the <a href="qqmlcontext.html">QQmlContext</a> for the <i>object</i>, or 0 if no context has been set.</p>
<p>When the <a href="qqmlengine.html">QQmlEngine</a> instantiates a QObject, the context is set automatically.</p>
<p><b>See also </b><a href="qqmlengine.html#setContextForObject">setContextForObject</a>().</p>
<!-- @@@contextForObject -->
<!-- $$$event[overload1]$$$eventQEvent* -->
<h3 class="fn"><a name="event"></a><span class="type">bool</span> QQmlEngine::<span class="name">event</span>(<span class="type">QEvent</span> *)<tt> [virtual protected]</tt></h3>
<!-- @@@event -->
<!-- $$$imageProvider[overload1]$$$imageProviderconstQString& -->
<h3 class="fn"><a name="imageProvider"></a><span class="type"><a href="qqmlimageproviderbase.html">QQmlImageProviderBase</a></span> * QQmlEngine::<span class="name">imageProvider</span>(const <span class="type">QString</span> &<i> providerId</i>) const</h3>
<p>Returns the image provider set for <i>providerId</i>.</p>
<p>Returns the provider if it was found; otherwise returns 0.</p>
<p><b>See also </b>QQuickImageProvider.</p>
<!-- @@@imageProvider -->
<!-- $$$importPathList[overload1]$$$importPathList -->
<h3 class="fn"><a name="importPathList"></a><span class="type">QStringList</span> QQmlEngine::<span class="name">importPathList</span>() const</h3>
<p>Returns the list of directories where the engine searches for installed modules in a URL-based directory structure.</p>
<p>For example, if <tt>/opt/MyApp/lib/imports</tt> is in the path, then QML that imports <tt>com.mycompany.Feature</tt> will cause the <a href="qqmlengine.html">QQmlEngine</a> to look in <tt>/opt/MyApp/lib/imports/com/mycompany/Feature/</tt> for the components provided by that module. A <tt>qmldir</tt> file is required for defining the type version mapping and possibly QML extensions plugins.</p>
<p>By default, the list contains the directory of the application executable, paths specified in the <tt>QML2_IMPORT_PATH</tt> environment variable, and the builtin <tt>Qml2ImportsPath</tt> from QLibraryInfo.</p>
<p><b>See also </b><a href="qqmlengine.html#addImportPath">addImportPath</a>() and <a href="qqmlengine.html#setImportPathList">setImportPathList</a>().</p>
<!-- @@@importPathList -->
<!-- $$$importPlugin[overload1]$$$importPluginconstQString&constQString&QList<QQmlError>* -->
<h3 class="fn"><a name="importPlugin"></a><span class="type">bool</span> QQmlEngine::<span class="name">importPlugin</span>(const <span class="type">QString</span> &<i> filePath</i>, const <span class="type">QString</span> &<i> uri</i>, <span class="type">QList</span><<span class="type"><a href="qqmlerror.html">QQmlError</a></span>> *<i> errors</i>)</h3>
<p>Imports the plugin named <i>filePath</i> with the <i>uri</i> provided. Returns true if the plugin was successfully imported; otherwise returns false.</p>
<p>On failure and if non-null, the <i>errors</i> list will have any errors which occurred prepended to it.</p>
<p>The plugin has to be a Qt plugin which implements the <a href="qqmlextensionplugin.html">QQmlExtensionPlugin</a> interface.</p>
<!-- @@@importPlugin -->
<!-- $$$incubationController[overload1]$$$incubationController -->
<h3 class="fn"><a name="incubationController"></a><span class="type"><a href="qqmlincubationcontroller.html">QQmlIncubationController</a></span> * QQmlEngine::<span class="name">incubationController</span>() const</h3>
<p>Returns the currently set incubation controller, or 0 if no controller has been set.</p>
<p><b>See also </b><a href="qqmlengine.html#setIncubationController">setIncubationController</a>().</p>
<!-- @@@incubationController -->
<!-- $$$networkAccessManager[overload1]$$$networkAccessManager -->
<h3 class="fn"><a name="networkAccessManager"></a><span class="type">QNetworkAccessManager</span> * QQmlEngine::<span class="name">networkAccessManager</span>() const</h3>
<p>Returns a common QNetworkAccessManager which can be used by any QML type instantiated by this engine.</p>
<p>If a <a href="qqmlnetworkaccessmanagerfactory.html">QQmlNetworkAccessManagerFactory</a> has been set and a QNetworkAccessManager has not yet been created, the <a href="qqmlnetworkaccessmanagerfactory.html">QQmlNetworkAccessManagerFactory</a> will be used to create the QNetworkAccessManager; otherwise the returned QNetworkAccessManager will have no proxy or cache set.</p>
<p><b>See also </b><a href="qqmlengine.html#setNetworkAccessManagerFactory">setNetworkAccessManagerFactory</a>().</p>
<!-- @@@networkAccessManager -->
<!-- $$$networkAccessManagerFactory[overload1]$$$networkAccessManagerFactory -->
<h3 class="fn"><a name="networkAccessManagerFactory"></a><span class="type"><a href="qqmlnetworkaccessmanagerfactory.html">QQmlNetworkAccessManagerFactory</a></span> * QQmlEngine::<span class="name">networkAccessManagerFactory</span>() const</h3>
<p>Returns the current <a href="qqmlnetworkaccessmanagerfactory.html">QQmlNetworkAccessManagerFactory</a>.</p>
<p><b>See also </b><a href="qqmlengine.html#setNetworkAccessManagerFactory">setNetworkAccessManagerFactory</a>().</p>
<!-- @@@networkAccessManagerFactory -->
<!-- $$$objectOwnership[overload1]$$$objectOwnershipQObject* -->
<h3 class="fn"><a name="objectOwnership"></a><span class="type"><a href="qqmlengine.html#ObjectOwnership-enum">ObjectOwnership</a></span> QQmlEngine::<span class="name">objectOwnership</span>(<span class="type">QObject</span> *<i> object</i>)<tt> [static]</tt></h3>
<p>Returns the ownership of <i>object</i>.</p>
<p><b>See also </b><a href="qqmlengine.html#setObjectOwnership">setObjectOwnership</a>().</p>
<!-- @@@objectOwnership -->
<!-- $$$outputWarningsToStandardError[overload1]$$$outputWarningsToStandardError -->
<h3 class="fn"><a name="outputWarningsToStandardError"></a><span class="type">bool</span> QQmlEngine::<span class="name">outputWarningsToStandardError</span>() const</h3>
<p>Returns true if warning messages will be output to stderr in addition to being emitted by the <a href="qqmlengine.html#warnings">warnings</a>() signal, otherwise false.</p>
<p>The default value is true.</p>
<p><b>See also </b><a href="qqmlengine.html#setOutputWarningsToStandardError">setOutputWarningsToStandardError</a>().</p>
<!-- @@@outputWarningsToStandardError -->
<!-- $$$pluginPathList[overload1]$$$pluginPathList -->
<h3 class="fn"><a name="pluginPathList"></a><span class="type">QStringList</span> QQmlEngine::<span class="name">pluginPathList</span>() const</h3>
<p>Returns the list of directories where the engine searches for native plugins for imported modules (referenced in the <tt>qmldir</tt> file).</p>
<p>By default, the list contains only <tt>.</tt>, i.e. the engine searches in the directory of the <tt>qmldir</tt> file itself.</p>
<p><b>See also </b><a href="qqmlengine.html#addPluginPath">addPluginPath</a>() and <a href="qqmlengine.html#setPluginPathList">setPluginPathList</a>().</p>
<!-- @@@pluginPathList -->
<!-- $$$quit[overload1]$$$quit -->
<h3 class="fn"><a name="quit"></a><span class="type">void</span> QQmlEngine::<span class="name">quit</span>()<tt> [signal]</tt></h3>
<p>This signal is emitted when the QML loaded by the engine would like to quit.</p>
<!-- @@@quit -->
<!-- $$$removeImageProvider[overload1]$$$removeImageProviderconstQString& -->
<h3 class="fn"><a name="removeImageProvider"></a><span class="type">void</span> QQmlEngine::<span class="name">removeImageProvider</span>(const <span class="type">QString</span> &<i> providerId</i>)</h3>
<p>Removes the image provider for <i>providerId</i>.</p>
<p><b>See also </b><a href="qqmlengine.html#addImageProvider">addImageProvider</a>() and QQuickImageProvider.</p>
<!-- @@@removeImageProvider -->
<!-- $$$rootContext[overload1]$$$rootContext -->
<h3 class="fn"><a name="rootContext"></a><span class="type"><a href="qqmlcontext.html">QQmlContext</a></span> * QQmlEngine::<span class="name">rootContext</span>() const</h3>
<p>Returns the engine's root context.</p>
<p>The root context is automatically created by the <a href="qqmlengine.html">QQmlEngine</a>. Data that should be available to all QML component instances instantiated by the engine should be put in the root context.</p>
<p>Additional data that should only be available to a subset of component instances should be added to sub-contexts parented to the root context.</p>
<!-- @@@rootContext -->
<!-- $$$setBaseUrl[overload1]$$$setBaseUrlconstQUrl& -->
<h3 class="fn"><a name="setBaseUrl"></a><span class="type">void</span> QQmlEngine::<span class="name">setBaseUrl</span>(const <span class="type">QUrl</span> &<i> url</i>)</h3>
<p>Set the base URL for this engine to <i>url</i>.</p>
<p><b>See also </b><a href="qqmlengine.html#baseUrl">baseUrl</a>().</p>
<!-- @@@setBaseUrl -->
<!-- $$$setContextForObject[overload1]$$$setContextForObjectQObject*QQmlContext* -->
<h3 class="fn"><a name="setContextForObject"></a><span class="type">void</span> QQmlEngine::<span class="name">setContextForObject</span>(<span class="type">QObject</span> *<i> object</i>, <span class="type"><a href="qqmlcontext.html">QQmlContext</a></span> *<i> context</i>)<tt> [static]</tt></h3>
<p>Sets the <a href="qqmlcontext.html">QQmlContext</a> for the <i>object</i> to <i>context</i>. If the <i>object</i> already has a context, a warning is output, but the context is not changed.</p>
<p>When the <a href="qqmlengine.html">QQmlEngine</a> instantiates a QObject, the context is set automatically.</p>
<p><b>See also </b><a href="qqmlengine.html#contextForObject">contextForObject</a>().</p>
<!-- @@@setContextForObject -->
<!-- $$$setImportPathList[overload1]$$$setImportPathListconstQStringList& -->
<h3 class="fn"><a name="setImportPathList"></a><span class="type">void</span> QQmlEngine::<span class="name">setImportPathList</span>(const <span class="type">QStringList</span> &<i> paths</i>)</h3>
<p>Sets <i>paths</i> as the list of directories where the engine searches for installed modules in a URL-based directory structure.</p>
<p>By default, the list contains the directory of the application executable, paths specified in the <tt>QML2_IMPORT_PATH</tt> environment variable, and the builtin <tt>Qml2ImportsPath</tt> from QLibraryInfo.</p>
<p><b>See also </b><a href="qqmlengine.html#importPathList">importPathList</a>() and <a href="qqmlengine.html#addImportPath">addImportPath</a>().</p>
<!-- @@@setImportPathList -->
<!-- $$$setIncubationController[overload1]$$$setIncubationControllerQQmlIncubationController* -->
<h3 class="fn"><a name="setIncubationController"></a><span class="type">void</span> QQmlEngine::<span class="name">setIncubationController</span>(<span class="type"><a href="qqmlincubationcontroller.html">QQmlIncubationController</a></span> *<i> controller</i>)</h3>
<p>Sets the engine's incubation <i>controller</i>. The engine can only have one active controller and it does not take ownership of it.</p>
<p><b>See also </b><a href="qqmlengine.html#incubationController">incubationController</a>().</p>
<!-- @@@setIncubationController -->
<!-- $$$setNetworkAccessManagerFactory[overload1]$$$setNetworkAccessManagerFactoryQQmlNetworkAccessManagerFactory* -->
<h3 class="fn"><a name="setNetworkAccessManagerFactory"></a><span class="type">void</span> QQmlEngine::<span class="name">setNetworkAccessManagerFactory</span>(<span class="type"><a href="qqmlnetworkaccessmanagerfactory.html">QQmlNetworkAccessManagerFactory</a></span> *<i> factory</i>)</h3>
<p>Sets the <i>factory</i> to use for creating QNetworkAccessManager(s).</p>
<p>QNetworkAccessManager is used for all network access by QML. By implementing a factory it is possible to create custom QNetworkAccessManager with specialized caching, proxy and cookie support.</p>
<p>The factory must be set before executing the engine.</p>
<p><b>See also </b><a href="qqmlengine.html#networkAccessManagerFactory">networkAccessManagerFactory</a>().</p>
<!-- @@@setNetworkAccessManagerFactory -->
<!-- $$$setObjectOwnership[overload1]$$$setObjectOwnershipQObject*ObjectOwnership -->
<h3 class="fn"><a name="setObjectOwnership"></a><span class="type">void</span> QQmlEngine::<span class="name">setObjectOwnership</span>(<span class="type">QObject</span> *<i> object</i>, <span class="type"><a href="qqmlengine.html#ObjectOwnership-enum">ObjectOwnership</a></span><i> ownership</i>)<tt> [static]</tt></h3>
<p>Sets the <i>ownership</i> of <i>object</i>.</p>
<p><b>See also </b><a href="qqmlengine.html#objectOwnership">objectOwnership</a>().</p>
<!-- @@@setObjectOwnership -->
<!-- $$$setOutputWarningsToStandardError[overload1]$$$setOutputWarningsToStandardErrorbool -->
<h3 class="fn"><a name="setOutputWarningsToStandardError"></a><span class="type">void</span> QQmlEngine::<span class="name">setOutputWarningsToStandardError</span>(<span class="type">bool</span><i> enabled</i>)</h3>
<p>Set whether warning messages will be output to stderr to <i>enabled</i>.</p>
<p>If <i>enabled</i> is true, any warning messages generated by QML will be output to stderr and emitted by the <a href="qqmlengine.html#warnings">warnings</a>() signal. If <i>enabled</i> is false, on the <a href="qqmlengine.html#warnings">warnings</a>() signal will be emitted. This allows applications to handle warning output themselves.</p>
<p>The default value is true.</p>
<p><b>See also </b><a href="qqmlengine.html#outputWarningsToStandardError">outputWarningsToStandardError</a>().</p>
<!-- @@@setOutputWarningsToStandardError -->
<!-- $$$setPluginPathList[overload1]$$$setPluginPathListconstQStringList& -->
<h3 class="fn"><a name="setPluginPathList"></a><span class="type">void</span> QQmlEngine::<span class="name">setPluginPathList</span>(const <span class="type">QStringList</span> &<i> paths</i>)</h3>
<p>Sets the list of directories where the engine searches for native plugins for imported modules (referenced in the <tt>qmldir</tt> file) to <i>paths</i>.</p>
<p>By default, the list contains only <tt>.</tt>, i.e. the engine searches in the directory of the <tt>qmldir</tt> file itself.</p>
<p><b>See also </b><a href="qqmlengine.html#pluginPathList">pluginPathList</a>() and <a href="qqmlengine.html#addPluginPath">addPluginPath</a>().</p>
<!-- @@@setPluginPathList -->
<!-- $$$trimComponentCache[overload1]$$$trimComponentCache -->
<h3 class="fn"><a name="trimComponentCache"></a><span class="type">void</span> QQmlEngine::<span class="name">trimComponentCache</span>()</h3>
<p>Trims the engine's internal component cache.</p>
<p>This function causes the property metadata of any loaded components which are not currently in use to be destroyed.</p>
<p>A component is considered to be in use if there are any extant instances of the component itself, any instances of other components that use the component, or any objects instantiated by any of those components.</p>
<p><b>See also </b><a href="qqmlengine.html#clearComponentCache">clearComponentCache</a>().</p>
<!-- @@@trimComponentCache -->
<!-- $$$warnings[overload1]$$$warningsconstQList<QQmlError>& -->
<h3 class="fn"><a name="warnings"></a><span class="type">void</span> QQmlEngine::<span class="name">warnings</span>(const <span class="type">QList</span><<span class="type"><a href="qqmlerror.html">QQmlError</a></span>> &<i> warnings</i>)<tt> [signal]</tt></h3>
<p>This signal is emitted when <i>warnings</i> messages are generated by QML.</p>
<!-- @@@warnings -->
</div>
<div class="relnonmem">
<h2>Related Non-Members</h2>
<!-- $$$qmlAttachedPropertiesObject[overload1]$$$qmlAttachedPropertiesObjectconstQObject*bool -->
<h3 class="fn"><a name="qmlAttachedPropertiesObject"></a><span class="type">QObject</span> * <span class="name">qmlAttachedPropertiesObject</span>(const <span class="type">QObject</span> *<i> attachee</i>, <span class="type">bool</span><i> create</i> = true)</h3>
<p>The form of this template function is:</p>
<pre class="cpp"><span class="keyword">template</span><span class="operator"><</span><span class="keyword">typename</span> T<span class="operator">></span> <span class="type">QObject</span> <span class="operator">*</span>qmlAttachedPropertiesObject(<span class="keyword">const</span> <span class="type">QObject</span> <span class="operator">*</span>attachee<span class="operator">,</span> bool create <span class="operator">=</span> <span class="keyword">true</span>)</pre>
<p>This returns the attached object instance that has been attached to the specified <i>attachee</i> by the attaching type <i>T</i>.</p>
<p>If <i>create</i> is true and type <i>T</i> is a valid attaching type, this creates and returns a new attached object instance.</p>
<p>Returns 0 if type <i>T</i> is not a valid attaching type, or if <i>create</i> is false and no attachment object instance has previously been created for <i>attachee</i>.</p>
<p><b>See also </b><a href="qtqml-cppintegration-definetypes.html#providing-attached-objects-for-data-annotations">Providing Attached Objects for Data Annotations</a>.</p>
<!-- @@@qmlAttachedPropertiesObject -->
<!-- $$$qmlClearTypeRegistrations[overload1]$$$qmlClearTypeRegistrations -->
<h3 class="fn"><a name="qmlClearTypeRegistrations"></a><span class="type">void</span> <span class="name">qmlClearTypeRegistrations</span>()</h3>
<p>Clears all stored type registrations, such as those produced with <a href="qqmlengine.html#qmlRegisterType">qmlRegisterType</a>().</p>
<p>Do not call this function while a <a href="qqmlengine.html">QQmlEngine</a> exists or behavior will be undefined. Any existing QQmlEngines must be deleted before calling this function. This function only affects the application global cache. Delete the <a href="qqmlengine.html">QQmlEngine</a> to clear all cached data relating to that engine.</p>
<p>#include <<a href="qtqml-module.html">QtQml</a>> to use this method.</p>
<!-- @@@qmlClearTypeRegistrations -->
<!-- $$$qmlProtectModule[overload1]$$$qmlProtectModuleconstchar*int -->
<h3 class="fn"><a name="qmlProtectModule"></a><span class="type">bool</span> <span class="name">qmlProtectModule</span>(const <span class="type">char</span> *<i> uri</i>, <span class="type">int</span><i> majVersion</i>)</h3>
<p>This function protects a module from having types registered into it. This can be used to prevent other plugins from injecting types into your module. It can also be a performance improvement, as it allows the engine to skip checking for the possibility of new types or plugins when this import is reached.</p>
<p>The performance benefit is primarily seen when registering application specific types from within the application instead of through a plugin. Using qmlProtectModule allows the engine to skip checking for a plugin when that uri is imported, which can be noticeable with slow file systems.</p>
<p>After this function is called, any attempt to register C++ types into this uri, major version combination will lead to a runtime error. Call this after you have registered all of your types with the engine.</p>
<p>#include <<a href="qtqml-module.html">QtQml</a>> to use this function.</p>
<p>Returns true if the module with <i>uri</i> as a <a href="qtqml-modules-identifiedmodules.html">module identifier</a> and <i>majVersion</i> as a major version number was found and locked, otherwise returns false. The module must contain exported types in order to be found.</p>
<!-- @@@qmlProtectModule -->
<!-- $$$qmlRegisterInterface[overload1]$$$qmlRegisterInterfaceconstchar* -->
<h3 class="fn"><a name="qmlRegisterInterface"></a><span class="type">int</span> <span class="name">qmlRegisterInterface</span>(const <span class="type">char</span> *<i> typeName</i>)</h3>
<p>This template function registers the C++ type in the QML system under the name <i>typeName</i>.</p>
<p>#include <<a href="qtqml-module.html">QtQml</a>> to use this function.</p>
<p>Returns the QML type id.</p>
<!-- @@@qmlRegisterInterface -->
<!-- $$$qmlRegisterRevision[overload1]$$$qmlRegisterRevisionconstchar*intint -->
<h3 class="fn"><a name="qmlRegisterRevision"></a><span class="type">int</span> <span class="name">qmlRegisterRevision</span>(const <span class="type">char</span> *<i> uri</i>, <span class="type">int</span><i> versionMajor</i>, <span class="type">int</span><i> versionMinor</i>)</h3>
<p>This template function registers the specified revision of a C++ type in the QML system with the library imported from <i>uri</i> having the version number composed from <i>versionMajor</i> and <i>versionMinor</i>.</p>
<p>Returns the QML type id.</p>
<pre class="cpp"><span class="keyword">template</span><span class="operator"><</span><span class="keyword">typename</span> T<span class="operator">,</span> <span class="type">int</span> metaObjectRevision<span class="operator">></span>
<span class="type">int</span> qmlRegisterRevision(<span class="keyword">const</span> <span class="type">char</span> <span class="operator">*</span>uri<span class="operator">,</span> <span class="type">int</span> versionMajor<span class="operator">,</span> <span class="type">int</span> versionMinor);</pre>
<p>This function is typically used to register the revision of a base class to use for the specified version of the type (see <a href="qtqml-cppintegration-definetypes.html#type-revisions-and-versions">Type Revisions and Versions</a>).</p>
<!-- @@@qmlRegisterRevision -->
<!-- $$$qmlRegisterSingletonType[overload1]$$$qmlRegisterSingletonTypeconstchar*intintconstchar*QJSValue(*)(QQmlEngine*,QJSEngine*) -->
<h3 class="fn"><a name="qmlRegisterSingletonType"></a><span class="type">int</span> <span class="name">qmlRegisterSingletonType</span>(const <span class="type">char</span> *<i> uri</i>, <span class="type">int</span><i> versionMajor</i>, <span class="type">int</span><i> versionMinor</i>, const <span class="type">char</span> *<i> typeName</i>, <span class="type"><a href="qjsvalue.html">QJSValue</a></span>(* ) ( <span class="type">QQmlEngine</span> *, <span class="type"><a href="qjsengine.html">QJSEngine</a></span> * )<i> callback</i>)</h3>
<p>This function may be used to register a singleton type provider <i>callback</i> in a particular <i>uri</i> and <i>typeName</i> with a version specified in <i>versionMajor</i> and <i>versionMinor</i>.</p>
<p>Installing a singleton type allows developers to provide arbitrary functionality (methods and properties) to a client without requiring individual instances of the type to be instantiated by the client.</p>
<p>A singleton type may be either a QObject or a <a href="qjsvalue.html">QJSValue</a>. This function should be used to register a singleton type provider function which returns a <a href="qjsvalue.html">QJSValue</a> as a singleton type.</p>
<p><b>NOTE:</b> <a href="qjsvalue.html">QJSValue</a> singleton type properties will <b>not</b> trigger binding re-evaluation if changed.</p>
<p>Usage:</p>
<pre class="cpp"><span class="comment">// First, define the singleton type provider function (callback).</span>
<span class="keyword">static</span> <span class="type"><a href="qjsvalue.html">QJSValue</a></span> <span class="operator">*</span>example_qjsvalue_singletontype_provider(<span class="type"><a href="qqmlengine.html">QQmlEngine</a></span> <span class="operator">*</span>engine<span class="operator">,</span> <span class="type"><a href="qjsengine.html">QJSEngine</a></span> <span class="operator">*</span>scriptEngine)
{
Q_UNUSED(engine)
<span class="keyword">static</span> <span class="type">int</span> seedValue <span class="operator">=</span> <span class="number">5</span>;
<span class="type"><a href="qjsvalue.html">QJSValue</a></span> example <span class="operator">=</span> scriptEngine<span class="operator">-</span><span class="operator">></span>newObject();
example<span class="operator">.</span>setProperty(<span class="string">"someProperty"</span><span class="operator">,</span> seedValue<span class="operator">+</span><span class="operator">+</span>);
<span class="keyword">return</span> example;
}
<span class="comment">// Second, register the singleton type provider with QML by calling this function in an initialization function.</span>
<span class="preprocessor">#include <QtQml></span>
<span class="operator">.</span><span class="operator">.</span><span class="operator">.</span>
qmlRegisterSingletonType(<span class="string">"Qt.example.qjsvalueApi"</span><span class="operator">,</span> <span class="number">1</span><span class="operator">,</span> <span class="number">0</span><span class="operator">,</span> <span class="string">"MyApi"</span><span class="operator">,</span> example_qjsvalue_singletontype_provider);
<span class="operator">.</span><span class="operator">.</span><span class="operator">.</span></pre>
<p>In order to use the registered singleton type in QML, you must import the singleton type.</p>
<pre class="qml">import QtQuick 2.0
import Qt.example.qjsvalueApi 1.0 as ExampleApi
<span class="type">Item</span> {
<span class="name">id</span>: <span class="name">root</span>
property <span class="type">int</span> <span class="name">someValue</span>: <span class="name">ExampleApi</span>.<span class="name">MyApi</span>.<span class="name">someProperty</span>
}</pre>
<!-- @@@qmlRegisterSingletonType -->
<!-- $$$qmlRegisterSingletonType$$$qmlRegisterSingletonTypeconstchar*intintconstchar*QObject*(*)(QQmlEngine*,QJSEngine*) -->
<h3 class="fn"><a name="qmlRegisterSingletonType-2"></a><span class="type">int</span> <span class="name">qmlRegisterSingletonType</span>(const <span class="type">char</span> *<i> uri</i>, <span class="type">int</span><i> versionMajor</i>, <span class="type">int</span><i> versionMinor</i>, const <span class="type">char</span> *<i> typeName</i>, <span class="type">QObject</span> *(* ) ( <span class="type">QQmlEngine</span> *, <span class="type"><a href="qjsengine.html">QJSEngine</a></span> * )<i> callback</i>)</h3>
<p>This function may be used to register a singleton type provider <i>callback</i> in a particular <i>uri</i> and <i>typeName</i> with a version specified in <i>versionMajor</i> and <i>versionMinor</i>.</p>
<p>Installing a singleton type into a uri allows developers to provide arbitrary functionality (methods and properties) to clients without requiring individual instances ot the type to be instantiated by the client.</p>
<p>A singleton type may be either a QObject or a <a href="qjsvalue.html">QJSValue</a>. This function should be used to register a singleton type provider function which returns a QObject of the given type T as a singleton type.</p>
<p>A QObject singleton type may be referenced via the type name with which it was registered, and this typename may be used as the target in a <a href="qml-qtqml-connections.html">Connections</a> type or otherwise used as any other type id would. One exception to this is that a QObject singleton type property may not be aliased (because the singleton type name does not identify an object within the same component as any other item).</p>
<p><b>NOTE:</b> A QObject singleton type instance returned from a singleton type provider is owned by the QML engine. For this reason, the singleton type provider function should <b>not</b> be implemented as a singleton factory.</p>
<p>Usage:</p>
<pre class="cpp"><span class="comment">// First, define your QObject which provides the functionality.</span>
<span class="keyword">class</span> SingletonTypeExample : <span class="keyword">public</span> <span class="type">QObject</span>
{
Q_OBJECT
Q_PROPERTY (<span class="type">int</span> someProperty READ someProperty WRITE setSomeProperty NOTIFY somePropertyChanged)
<span class="keyword">public</span>:
SingletonTypeExample(<span class="type">QObject</span><span class="operator">*</span> parent <span class="operator">=</span> <span class="number">0</span>)
: <span class="type">QObject</span>(parent)<span class="operator">,</span> m_someProperty(<span class="number">0</span>)
{
}
<span class="operator">~</span>SingletonTypeExample() {}
Q_INVOKABLE <span class="type">int</span> doSomething() { setSomeProperty(<span class="number">5</span>); <span class="keyword">return</span> m_someProperty; }
<span class="type">int</span> someProperty() <span class="keyword">const</span> { <span class="keyword">return</span> m_someProperty; }
<span class="type">void</span> setSomeProperty(<span class="type">int</span> val) { m_someProperty <span class="operator">=</span> val; <span class="keyword">emit</span> somePropertyChanged(val); }
<span class="keyword">signals</span>:
<span class="type">void</span> somePropertyChanged(<span class="type">int</span> newValue);
<span class="keyword">private</span>:
<span class="type">int</span> m_someProperty;
};
<span class="comment">// Second, define the singleton type provider function (callback).</span>
<span class="keyword">static</span> <span class="type">QObject</span> <span class="operator">*</span>example_qobject_singletontype_provider(<span class="type"><a href="qqmlengine.html">QQmlEngine</a></span> <span class="operator">*</span>engine<span class="operator">,</span> <span class="type"><a href="qjsengine.html">QJSEngine</a></span> <span class="operator">*</span>scriptEngine)
{
Q_UNUSED(engine)
Q_UNUSED(scriptEngine)
SingletonTypeExample <span class="operator">*</span>example <span class="operator">=</span> <span class="keyword">new</span> SingletonTypeExample();
<span class="keyword">return</span> example;
}
<span class="comment">// Third, register the singleton type provider with QML by calling this function in an initialization function.</span>
<span class="preprocessor">#include <QtQml></span>
<span class="operator">.</span><span class="operator">.</span><span class="operator">.</span>
qmlRegisterSingletonType<span class="operator"><</span>SingletonTypeExample<span class="operator">></span>(<span class="string">"Qt.example.qobjectSingleton"</span><span class="operator">,</span> <span class="number">1</span><span class="operator">,</span> <span class="number">0</span><span class="operator">,</span> <span class="string">"MyApi"</span><span class="operator">,</span> example_qobject_singletontype_provider);
<span class="operator">.</span><span class="operator">.</span><span class="operator">.</span></pre>
<p>In order to use the registered singleton type in QML, you must import the singleton type.</p>
<pre class="qml">import QtQuick 2.0
import Qt.example.qobjectSingleton 1.0
<span class="type">Item</span> {
<span class="name">id</span>: <span class="name">root</span>
property <span class="type">int</span> <span class="name">someValue</span>: <span class="name">MyApi</span>.<span class="name">someProperty</span>
<span class="name">Component</span>.onCompleted: {
<span class="name">someValue</span> <span class="operator">=</span> <span class="name">MyApi</span>.<span class="name">doSomething</span>()
}
}</pre>
<p>Since singleton types do not have an associated <a href="qqmlcontext.html">QQmlContext</a> object, then within the functions of a QObject-derived type that is registered as a singleton type implementation the QML context and engine information is not available. The <a href="qqmlengine.html#contextForObject">QQmlEngine::contextForObject</a>() function returns NULL when supplied with a pointer to an QObject that implements a singleton type.</p>
<p>Extending the above example:</p>
<pre class="cpp"><span class="keyword">class</span> SingletonTypeExample : <span class="keyword">public</span> <span class="type">QObject</span>
{
<span class="operator">.</span><span class="operator">.</span><span class="operator">.</span>
Q_INVOKABLE <span class="type">void</span> doSomethingElse()
{
<span class="comment">// QML Engine/Context information is not accessible here:</span>
Q_ASSERT(<span class="type"><a href="qqmlengine.html">QQmlEngine</a></span><span class="operator">::</span>contextForObject(<span class="keyword">this</span>) <span class="operator">=</span><span class="operator">=</span> <span class="number">0</span>);
Q_ASSERT(qmlContext(<span class="keyword">this</span>) <span class="operator">=</span><span class="operator">=</span> <span class="number">0</span>);
Q_ASSERT(qmlEngine(<span class="keyword">this</span>) <span class="operator">=</span><span class="operator">=</span> <span class="number">0</span>);
}
<span class="operator">.</span><span class="operator">.</span><span class="operator">.</span>
}</pre>
<!-- @@@qmlRegisterSingletonType -->
<!-- $$$qmlRegisterSingletonType$$$qmlRegisterSingletonTypeconstQUrl&constchar*intintconstchar* -->
<h3 class="fn"><a name="qmlRegisterSingletonType-3"></a><span class="type">int</span> <span class="name">qmlRegisterSingletonType</span>(const <span class="type">QUrl</span> &<i> url</i>, const <span class="type">char</span> *<i> uri</i>, <span class="type">int</span><i> versionMajor</i>, <span class="type">int</span><i> versionMinor</i>, const <span class="type">char</span> *<i> qmlName</i>)</h3>
<p>This function may be used to register a singleton type with the name <i>qmlName</i>, in the library imported from <i>uri</i> having the version number composed from <i>versionMajor</i> and <i>versionMinor</i>. The type is defined by the QML file located at <i>url</i>. The url must be an absolute URL, i.e. url.isRelative() == false.</p>
<p>In addition the type's QML file must have pragma Singleton statement among its import statements.</p>
<p>A singleton type may be referenced via the type name with which it was registered, and this typename may be used as the target in a <a href="qml-qtqml-connections.html">Connections</a> type or otherwise used as any other type id would. One exception to this is that a singleton type property may not be aliased (because the singleton type name does not identify an object within the same component as any other item).</p>
<p>Usage: // First, define your QML singleton type which provides the functionality.</p>
<pre class="qml">pragma Singleton
import QtQuick 2.0
<span class="type">Item</span> {
property <span class="type">int</span> <span class="name">testProp1</span>: <span class="number">125</span>
}</pre>
<pre class="cpp"><span class="comment">// Second, register the QML singleton type by calling this function in an initialization function.</span>
<span class="preprocessor">#include <QtQml></span>
<span class="operator">.</span><span class="operator">.</span><span class="operator">.</span>
<a href="qqmlengine.html#qmlRegisterSingletonType">qmlRegisterSingletonType</a>(<span class="type">QUrl</span>(<span class="string">"file:///absolute/path/SingletonType.qml"</span>)<span class="operator">,</span> <span class="string">"Qt.example.qobjectSingleton"</span><span class="operator">,</span> <span class="number">1</span><span class="operator">,</span> <span class="number">0</span><span class="operator">,</span> <span class="string">"RegisteredSingleton"</span>);
<span class="operator">.</span><span class="operator">.</span><span class="operator">.</span></pre>
<p>In order to use the registered singleton type in QML, you must import the singleton type.</p>
<pre class="qml">import QtQuick 2.0
import Qt.example.qobjectSingleton 1.0
<span class="type">Item</span> {
<span class="name">id</span>: <span class="name">root</span>
property <span class="type">int</span> <span class="name">someValue</span>: <span class="name">RegisteredSingleton</span>.<span class="name">testProp1</span>
}</pre>
<p>It is also possible to have QML singleton types registered without using the qmlRegisterSingletonType function. That can be done by adding a pragma Singleton statement among the imports of the type's QML file. In addition the type must be defined in a qmldir file with a singleton keyword and the qmldir must be imported by the QML files using the singleton.</p>
<!-- @@@qmlRegisterSingletonType -->
<!-- $$$qmlRegisterType[overload1]$$$qmlRegisterTypeconstchar*intintconstchar* -->
<h3 class="fn"><a name="qmlRegisterType"></a><span class="type">int</span> <span class="name">qmlRegisterType</span>(const <span class="type">char</span> *<i> uri</i>, <span class="type">int</span><i> versionMajor</i>, <span class="type">int</span><i> versionMinor</i>, const <span class="type">char</span> *<i> qmlName</i>)</h3>
<p>This template function registers the C++ type in the QML system with the name <i>qmlName</i>, in the library imported from <i>uri</i> having the version number composed from <i>versionMajor</i> and <i>versionMinor</i>.</p>
<p>Returns the QML type id.</p>
<p>There are two forms of this template function:</p>
<pre class="cpp"><span class="keyword">template</span><span class="operator"><</span><span class="keyword">typename</span> T<span class="operator">></span>
<span class="type">int</span> qmlRegisterType(<span class="keyword">const</span> <span class="type">char</span> <span class="operator">*</span>uri<span class="operator">,</span> <span class="type">int</span> versionMajor<span class="operator">,</span> <span class="type">int</span> versionMinor<span class="operator">,</span> <span class="keyword">const</span> <span class="type">char</span> <span class="operator">*</span>qmlName);
<span class="keyword">template</span><span class="operator"><</span><span class="keyword">typename</span> T<span class="operator">,</span> <span class="type">int</span> metaObjectRevision<span class="operator">></span>
<span class="type">int</span> qmlRegisterType(<span class="keyword">const</span> <span class="type">char</span> <span class="operator">*</span>uri<span class="operator">,</span> <span class="type">int</span> versionMajor<span class="operator">,</span> <span class="type">int</span> versionMinor<span class="operator">,</span> <span class="keyword">const</span> <span class="type">char</span> <span class="operator">*</span>qmlName);</pre>
<p>The former is the standard form which registers the type <i>T</i> as a new type. The latter allows a particular revision of a class to be registered in a specified version (see <a href="qtqml-cppintegration-definetypes.html#type-revisions-and-versions">Type Revisions and Versions</a>).</p>
<p>For example, this registers a C++ class <tt>MySliderItem</tt> as a QML type named <tt>Slider</tt> for version 1.0 of a type namespace called "com.mycompany.qmlcomponents":</p>
<pre class="cpp"><span class="preprocessor">#include <QtQml></span>
<span class="operator">.</span><span class="operator">.</span><span class="operator">.</span>
qmlRegisterType<span class="operator"><</span>MySliderItem<span class="operator">></span>(<span class="string">"com.mycompany.qmlcomponents"</span><span class="operator">,</span> <span class="number">1</span><span class="operator">,</span> <span class="number">0</span><span class="operator">,</span> <span class="string">"Slider"</span>);</pre>
<p>Once this is registered, the type can be used in QML by importing the specified type namespace and version number:</p>
<pre class="qml">import com.mycompany.qmlcomponents 1.0
<span class="type">Slider</span> {
<span class="comment">// ...</span>
}</pre>
<p>Note that it's perfectly reasonable for a library to register types to older versions than the actual version of the library. Indeed, it is normal for the new library to allow QML written to previous versions to continue to work, even if more advanced versions of some of its types are available.</p>
<!-- @@@qmlRegisterType -->
<!-- $$$qmlRegisterType$$$qmlRegisterTypeconstQUrl&constchar*intintconstchar* -->
<h3 class="fn"><a name="qmlRegisterType-3"></a><span class="type">int</span> <span class="name">qmlRegisterType</span>(const <span class="type">QUrl</span> &<i> url</i>, const <span class="type">char</span> *<i> uri</i>, <span class="type">int</span><i> versionMajor</i>, <span class="type">int</span><i> versionMinor</i>, const <span class="type">char</span> *<i> qmlName</i>)</h3>
<p>This function registers a type in the QML system with the name <i>qmlName</i>, in the library imported from <i>uri</i> having the version number composed from <i>versionMajor</i> and <i>versionMinor</i>. The type is defined by the QML file located at <i>url</i>. The url must be an absolute URL, i.e. url.isRelative() == false.</p>
<p>Normally QML files can be loaded as types directly from other QML files, or using a qmldir file. This function allows registration of files to types from C++ code, such as when the type mapping needs to be procedurally determined at startup.</p>
<p>#include <<a href="qtqml-module.html">QtQml</a>> to use this function.</p>
<p>Returns non-zero if the registration was sucessful.</p>
<!-- @@@qmlRegisterType -->
<!-- $$$qmlRegisterType$$$qmlRegisterType -->
<h3 class="fn"><a name="qmlRegisterType-4"></a><span class="type">int</span> <span class="name">qmlRegisterType</span>()</h3>
<p>This is an overloaded function.</p>
<p>This template function registers the C++ type in the QML system. Instances of this type cannot be created from the QML system.</p>
<p>#include <<a href="qtqml-module.html">QtQml</a>> to use this function.</p>
<p>Returns the QML type id.</p>
<!-- @@@qmlRegisterType -->
<!-- $$$qmlRegisterTypeNotAvailable[overload1]$$$qmlRegisterTypeNotAvailableconstchar*intintconstchar*constQString& -->
<h3 class="fn"><a name="qmlRegisterTypeNotAvailable"></a><span class="type">int</span> <span class="name">qmlRegisterTypeNotAvailable</span>(const <span class="type">char</span> *<i> uri</i>, <span class="type">int</span><i> versionMajor</i>, <span class="type">int</span><i> versionMinor</i>, const <span class="type">char</span> *<i> qmlName</i>, const <span class="type">QString</span> &<i> message</i>)</h3>
<p>This function registers a type in the QML system with the name <i>qmlName</i>, in the type namespace imported from <i>uri</i> having the version number composed from <i>versionMajor</i> and <i>versionMinor</i>, but any attempt to instantiate the type will produce the given error <i>message</i>.</p>
<p>Normally, the types exported by a plugin should be fixed. However, if a C++ type is not available, you should at least "reserve" the QML type name, and give the user of the unavailable type a meaningful error message.</p>
<p>Returns the QML type id.</p>
<p>Example:</p>
<pre class="cpp"><span class="preprocessor">#ifdef NO_GAMES_ALLOWED</span>
qmlRegisterTypeNotAvailable(<span class="string">"MinehuntCore"</span><span class="operator">,</span> <span class="number">0</span><span class="operator">,</span> <span class="number">1</span><span class="operator">,</span> <span class="string">"Game"</span><span class="operator">,</span> <span class="string">"Get back to work, slacker!"</span>);
<span class="preprocessor">#else</span>
qmlRegisterType<span class="operator"><</span>MinehuntGame<span class="operator">></span>(<span class="string">"MinehuntCore"</span><span class="operator">,</span> <span class="number">0</span><span class="operator">,</span> <span class="number">1</span><span class="operator">,</span> <span class="string">"Game"</span>);
<span class="preprocessor">#endif</span></pre>
<p>This will cause any QML which imports the "MinehuntCore" type namespace and attempts to use the type to produce an error message:</p>
<pre class="cpp">fun<span class="operator">.</span>qml: Get back to work<span class="operator">,</span> slacker<span class="operator">!</span>
Game {
<span class="operator">^</span></pre>
<p>Without this, a generic "Game is not a type" message would be given.</p>
<p>#include <<a href="qtqml-module.html">QtQml</a>> to use this function.</p>
<p><b>See also </b><a href="qqmlengine.html#qmlRegisterUncreatableType">qmlRegisterUncreatableType</a>().</p>
<!-- @@@qmlRegisterTypeNotAvailable -->
<!-- $$$qmlRegisterUncreatableType[overload1]$$$qmlRegisterUncreatableTypeconstchar*intintconstchar*constQString& -->
<h3 class="fn"><a name="qmlRegisterUncreatableType"></a><span class="type">int</span> <span class="name">qmlRegisterUncreatableType</span>(const <span class="type">char</span> *<i> uri</i>, <span class="type">int</span><i> versionMajor</i>, <span class="type">int</span><i> versionMinor</i>, const <span class="type">char</span> *<i> qmlName</i>, const <span class="type">QString</span> &<i> message</i>)</h3>
<p>This template function registers the C++ type in the QML system with the name <i>qmlName</i>, in the library imported from <i>uri</i> having the version number composed from <i>versionMajor</i> and <i>versionMinor</i>.</p>
<p>While the type has a name and a type, it cannot be created, and the given error <i>message</i> will result if creation is attempted.</p>
<p>This is useful where the type is only intended for providing attached properties or enum values.</p>
<p>Returns the QML type id.</p>
<p>#include <<a href="qtqml-module.html">QtQml</a>> to use this function.</p>
<p><b>See also </b><a href="qqmlengine.html#qmlRegisterTypeNotAvailable">qmlRegisterTypeNotAvailable</a>().</p>
<!-- @@@qmlRegisterUncreatableType -->
</div>
<div class="macros">
<h2>Macro Documentation</h2>
<!-- $$$QML_DECLARE_TYPE[overload1]$$$QML_DECLARE_TYPE -->
<h3 class="fn"><a name="QML_DECLARE_TYPE"></a><span class="name">QML_DECLARE_TYPE</span>()</h3>
<p>Equivalent to <tt>Q_DECLARE_METATYPE(TYPE *)</tt> and <tt>Q_DECLARE_METATYPE(QQmlListProperty<TYPE>)</tt></p>
<p>#include <<a href="qtqml-module.html">QtQml</a>> to use this macro.</p>
<!-- @@@QML_DECLARE_TYPE -->
<!-- $$$QML_DECLARE_TYPEINFO[overload1]$$$QML_DECLARE_TYPEINFO -->
<h3 class="fn"><a name="QML_DECLARE_TYPEINFO"></a><span class="name">QML_DECLARE_TYPEINFO</span>(<i> Type</i>, <i> Flags</i>)</h3>
<p>Declares additional properties of the given <i>Type</i> as described by the specified <i>Flags</i>.</p>
<p>Current the only supported type info is <tt>QML_HAS_ATTACHED_PROPERTIES</tt> which declares that the <i>Type</i> supports <a href="qtqml-syntax-objectattributes.html#attached-properties-and-attached-signal-handlers">attached properties</a>.</p>
<p>#include <<a href="qtqml-module.html">QtQml</a>> to use this macro.</p>
<!-- @@@QML_DECLARE_TYPEINFO -->
</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>
|