/usr/share/qt5/doc/qtqml/qtqml-documents-structure.html is in qtdeclarative5-doc-html 5.5.1-2ubuntu6.
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 | <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- structure.qdoc -->
<title>Structure of a QML Document | Qt QML 5.5</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.5</li>
<li><a href="qtqml-index.html">Qt QML</a></li>
<li>Structure of a QML Document</li>
<li id="buildversion">Qt 5.5.1 Reference Documentation</li>
</ul>
</div>
</div>
<div class="content">
<div class="line">
<div class="content mainContent">
<div class="sidebar">
<div class="toc">
<h3><a name="toc">Contents</a></h3>
<ul>
<li class="level1"><a href="#imports">Imports</a></li>
<li class="level1"><a href="#the-root-object-declaration">The Root Object Declaration</a></li>
</ul>
</div>
<div class="sidebar-content" id="sidebar-content"></div></div>
<h1 class="title">Structure of a QML Document</h1>
<span class="subtitle"></span>
<!-- $$$qtqml-documents-structure.html-description -->
<div class="descr"> <a name="details"></a>
<p>A QML document is a self contained piece of QML source code that consists of two parts:</p>
<ul>
<li>Its <i>import</i> statements</li>
<li>A single root object declaration</li>
</ul>
<p>By convention, a single empty line separates the imports from the object hierarchy definition.</p>
<p>QML documents are always encoded in UTF-8 format.</p>
<a name="imports"></a>
<h2 id="imports">Imports</h2>
<p>A document must import the necessary modules or type namespaces to enable the engine to load the QML object types referenced within the document. By default, a document can access any QML object types that have been defined through <code>.qml</code> files in the same directory; if a document needs to refer to any other object types, it must import the type namespace into which those types have been registered.</p>
<p>QML does <i>not</i> have a preprocessor that modifies the document prior to presentation to the <a href="qqmlengine.html">QML engine</a>, unlike C or C++. The <code>import</code> statements do not copy and prepend the code in the document, but instead instruct the QML engine on how to resolve type references found in the document. Any type reference present in a QML document - such as <code>Rectangle</code> and <code>ListView</code> - including those made within a <a href="qtqml-javascript-expressions.html">JavaScript block</a> or <a href="qtqml-syntax-propertybinding.html">property bindings</a>, are <i>resolved</i> based exclusively on the import statements. At least one <code>import</code> statement must be present such as <code>import QtQuick 2.0</code>.</p>
<p>Please see the <a href="qtqml-syntax-imports.html">QML Syntax - Import Statements</a> documentation for in-depth information about QML imports.</p>
<a name="the-root-object-declaration"></a>
<h2 id="the-root-object-declaration">The Root Object Declaration</h2>
<p>A QML document describes a hierarchy of objects which can be instantiated. Each object definition has a certain structure; it has a type, it can have an id and an object name, it can have properties, it can have methods, it can have signals and it can have signal handlers.</p>
<p>A QML file must only contain <b>a single root object definition</b>. The following is invalid and will generate an error:</p>
<pre class="cpp"><span class="comment">// MyQmlFile.qml</span>
import <span class="type">QtQuick</span> <span class="number">2.0</span>
Rectangle { width: <span class="number">200</span>; height: <span class="number">200</span>; color: <span class="string">"red"</span> }
Rectangle { width: <span class="number">200</span>; height: <span class="number">200</span>; color: <span class="string">"blue"</span> } <span class="comment">// invalid!</span></pre>
<p>This is because a .qml file automatically defines a QML type, which encapsulates a <i>single</i> QML object definition. This is discussed further in <a href="qtqml-documents-definetypes.html">Documents as QML object type definitions</a>.</p>
</div>
<!-- @@@qtqml-documents-structure.html -->
</div>
</div>
</div>
</div>
</div>
<div class="footer">
<p>
<acronym title="Copyright">©</acronym> 2015 The Qt Company Ltd.
Documentation contributions included herein are the copyrights of
their respective owners.<br> The documentation provided herein is licensed under the terms of the <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation License version 1.3</a> as published by the Free Software Foundation.<br> Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property
of their respective owners. </p>
</div>
</body>
</html>
|