This file is indexed.

/usr/share/qt5/doc/qtqml/qml-qtqml-component.html is in qtdeclarative5-doc-html 5.9.5-0ubuntu1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- qqmlcomponent.cpp -->
  <title>Component QML Type | Qt QML 5.9</title>
  <link rel="stylesheet" type="text/css" href="style/offline-simple.css" />
  <script type="text/javascript">
    document.getElementsByTagName("link").item(0).setAttribute("href", "style/offline.css");
    // loading style sheet breaks anchors that were jumped to before
    // so force jumping to anchor again
    setTimeout(function() {
        var anchor = location.hash;
        // need to jump to different anchor first (e.g. none)
        location.hash = "#";
        setTimeout(function() {
            location.hash = anchor;
        }, 0);
    }, 0);
  </script>
</head>
<body>
<div class="header" id="qtdocheader">
  <div class="main">
    <div class="main-rounded">
      <div class="navigationbar">
        <table><tr>
<td >Qt 5.9</td><td ><a href="qtqml-index.html">Qt QML</a></td><td ><a href="qtqml-qmlmodule.html">QML Types</a></td><td >Component QML Type</td></tr></table><table class="buildversion"><tr>
<td id="buildversion" width="100%" align="right">Qt 5.9.5 Reference Documentation</td>
        </tr></table>
      </div>
    </div>
<div class="content">
<div class="line">
<div class="content mainContent">
<div class="sidebar">
<div class="toc">
<h3><a name="toc">Contents</a></h3>
<ul>
<li class="level1"><a href="#properties">Properties</a></li>
<li class="level1"><a href="#attached-signals">Attached Signals</a></li>
<li class="level1"><a href="#methods">Methods</a></li>
<li class="level1"><a href="#details">Detailed Description</a></li>
<li class="level2"><a href="#creation-context">Creation Context</a></li>
</ul>
</div>
<div class="sidebar-content" id="sidebar-content"></div></div>
<h1 class="title">Component QML Type</h1>
<span class="subtitle"></span>
<!-- $$$Component-brief -->
<p>Encapsulates a QML component definition <a href="#details">More...</a></p>
<!-- @@@Component -->
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> Import Statement:</td><td class="memItemRight bottomAlign"> import QtQml 2.2</td></tr><tr><td class="memItemLeft rightAlign topAlign"> Instantiates:</td><td class="memItemRight bottomAlign"> <a href="qml-qtqml-component.html"><a href="qqmlcomponent.html">QQmlComponent</a></td></tr></table></div><ul>
<li><a href="qml-qtqml-component-members.html">List of all members, including inherited members</a></li>
</ul>
<a name="properties"></a>
<h2 id="properties">Properties</h2>
<ul>
<li class="fn"><b><b><a href="qml-qtqml-component.html#progress-prop">progress</a></b></b> : real</li>
<li class="fn"><b><b><a href="qml-qtqml-component.html#status-prop">status</a></b></b> : enumeration</li>
<li class="fn"><b><b><a href="qml-qtqml-component.html#url-prop">url</a></b></b> : url</li>
</ul>
<a name="attached-signals"></a>
<h2 id="attached-signals">Attached Signals</h2>
<ul>
<li class="fn"><b><b><a href="qml-qtqml-component.html#completed-signal">completed</a></b></b>()</li>
<li class="fn"><b><b><a href="qml-qtqml-component.html#destruction-signal">destruction</a></b></b>()</li>
</ul>
<a name="methods"></a>
<h2 id="methods">Methods</h2>
<ul>
<li class="fn">object <b><b><a href="qml-qtqml-component.html#createObject-method">createObject</a></b></b>(QtObject <i>parent</i>, object <i>properties</i>)</li>
<li class="fn">string <b><b><a href="qml-qtqml-component.html#errorString-method">errorString</a></b></b>()</li>
<li class="fn">object <b><b><a href="qml-qtqml-component.html#incubateObject-method">incubateObject</a></b></b>(Item <i>parent</i>, object <i>properties</i>, enumeration <i>mode</i>)</li>
</ul>
<!-- $$$Component-description -->
<a name="details"></a>
<h2 id="details">Detailed Description</h2>
<p>Components are reusable, encapsulated QML types with well-defined interfaces.</p>
<p>Components are often defined by <a href="qtqml-documents-topic.html">component files</a> - that is, <code>.qml</code> files. The <i>Component</i> type essentially allows QML components to be defined inline, within a <a href="qtqml-documents-topic.html">QML document</a>, rather than as a separate QML file. This may be useful for reusing a small component within a QML file, or for defining a component that logically belongs with other QML components within a file.</p>
<p>For example, here is a component that is used by multiple Loader objects. It contains a single item, a Rectangle:</p>
<pre class="qml">

  import QtQuick 2.0

  <span class="type">Item</span> {
      <span class="name">width</span>: <span class="number">100</span>; <span class="name">height</span>: <span class="number">100</span>

      <span class="type"><a href="qml-qtqml-component.html">Component</a></span> {
          <span class="name">id</span>: <span class="name">redSquare</span>

          <span class="type">Rectangle</span> {
              <span class="name">color</span>: <span class="string">&quot;red&quot;</span>
              <span class="name">width</span>: <span class="number">10</span>
              <span class="name">height</span>: <span class="number">10</span>
          }
      }

      <span class="type">Loader</span> { <span class="name">sourceComponent</span>: <span class="name">redSquare</span> }
      <span class="type">Loader</span> { <span class="name">sourceComponent</span>: <span class="name">redSquare</span>; <span class="name">x</span>: <span class="number">20</span> }
  }

</pre>
<p>Notice that while a Rectangle by itself would be automatically rendered and displayed, this is not the case for the above rectangle because it is defined inside a <code>Component</code>. The component encapsulates the QML types within, as if they were defined in a separate QML file, and is not loaded until requested (in this case, by the two Loader objects). Because Component is not derived from Item, you cannot anchor anything to it.</p>
<p>Defining a <code>Component</code> is similar to defining a <a href="qtqml-documents-topic.html">QML document</a>. A QML document has a single top-level item that defines the behavior and properties of that component, and cannot define properties or behavior outside of that top-level item. In the same way, a <code>Component</code> definition contains a single top level item (which in the above example is a Rectangle) and cannot define any data outside of this item, with the exception of an <i>id</i> (which in the above example is <i>redSquare</i>).</p>
<p>The <code>Component</code> type is commonly used to provide graphical components for views. For example, the ListView::delegate property requires a <code>Component</code> to specify how each list item is to be displayed.</p>
<p><code>Component</code> objects can also be created dynamically using <a href="qml-qtqml-qt.html#createComponent-method">Qt.createComponent()</a>.</p>
<a name="creation-context"></a>
<h3 >Creation Context</h3>
<p>The creation context of a Component corresponds to the context where the Component was declared. This context is used as the parent context (creating a <a href="qtqml-documents-scope.html#component-instance-hierarchy">context hierarchy</a>) when the component is instantiated by an object such as a ListView or a Loader.</p>
<p>In the following example, <code>comp1</code> is created within the root context of MyItem.qml, and any objects instantiated from this component will have access to the ids and properties within that context, such as <code>internalSettings.color</code>. When <code>comp1</code> is used as a ListView delegate in another context (as in main.qml below), it will continue to have access to the properties of its creation context (which would otherwise be private to external users).</p>
<div class="table"><table class="generic">
 <tr valign="top" class="odd"><td >MyItem.qml</td><td ><pre class="qml">

  <span class="type">Item</span> {
      property <span class="type"><a href="qml-qtqml-component.html">Component</a></span> <span class="name">mycomponent</span>: <span class="name">comp1</span>

      <span class="type"><a href="qml-qtqml-qtobject.html">QtObject</a></span> {
          <span class="name">id</span>: <span class="name">internalSettings</span>
          property <span class="type">color</span> <span class="name">color</span>: <span class="string">&quot;green&quot;</span>
      }

      <span class="type"><a href="qml-qtqml-component.html">Component</a></span> {
          <span class="name">id</span>: <span class="name">comp1</span>
          <span class="type">Rectangle</span> { <span class="name">color</span>: <span class="name">internalSettings</span>.<span class="name">color</span>; <span class="name">width</span>: <span class="number">400</span>; <span class="name">height</span>: <span class="number">50</span> }
      }
  }

</pre>
</td></tr>
<tr valign="top" class="even"><td >main.qml</td><td ><pre class="qml">

  <span class="type">ListView</span> {
      <span class="name">width</span>: <span class="number">400</span>; <span class="name">height</span>: <span class="number">400</span>
      <span class="name">model</span>: <span class="number">5</span>
      <span class="name">delegate</span>: <span class="name">myItem</span>.<span class="name">mycomponent</span>    <span class="comment">//will create green Rectangles</span>

      <span class="type">MyItem</span> { <span class="name">id</span>: <span class="name">myItem</span> }
  }

</pre>
</td></tr>
</table></div>
<!-- @@@Component -->
<h2>Property Documentation</h2>
<!-- $$$progress -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="progress-prop">
<td class="tblQmlPropNode"><p>
<a name="progress-prop"></a><span class="name">progress</span> : <span class="type">real</span></p></td></tr>
</table></div>
</div><div class="qmldoc"><p>The progress of loading the component, from 0.0 (nothing loaded) to 1.0 (finished).</p>
</div></div><!-- @@@progress -->
<br/>
<!-- $$$status -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="status-prop">
<td class="tblQmlPropNode"><p>
<a name="status-prop"></a><span class="name">status</span> : <span class="type">enumeration</span></p></td></tr>
</table></div>
</div><div class="qmldoc"><p>This property holds the status of component loading. The status can be one of the following:</p>
<ul>
<li>Component.Null - no data is available for the component</li>
<li>Component.Ready - the component has been loaded, and can be used to create instances.</li>
<li>Component.Loading - the component is currently being loaded</li>
<li>Component.Error - an error occurred while loading the component. Calling <a href="qml-qtqml-component.html#errorString-method">errorString()</a> will provide a human-readable description of any errors.</li>
</ul>
</div></div><!-- @@@status -->
<br/>
<!-- $$$url -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="url-prop">
<td class="tblQmlPropNode"><p>
<a name="url-prop"></a><span class="name">url</span> : <span class="type"><a href="qml-qtqml-component.html#url-prop">url</a></span></p></td></tr>
</table></div>
</div><div class="qmldoc"><p>The component URL. This is the URL that was used to construct the component.</p>
</div></div><!-- @@@url -->
<br/>
<h2>Attached Signal Documentation</h2>
<!-- $$$completed -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="completed-signal">
<td class="tblQmlFuncNode"><p>
<a name="completed-signal"></a><span class="name">completed</span>()</p></td></tr>
</table></div>
</div><div class="qmldoc"><p>Emitted after the object has been instantiated. This can be used to execute script code at startup, once the full QML environment has been established.</p>
<p>The corresponding handler is <code>onCompleted</code>. It can be declared on any object. The order of running the <code>onCompleted</code> handlers is undefined.</p>
<pre class="qml">

  <span class="type">Rectangle</span> {
      <span class="name">Component</span>.onCompleted: <span class="name">console</span>.<span class="name">log</span>(<span class="string">&quot;Completed Running!&quot;</span>)
      <span class="type">Rectangle</span> {
          <span class="name">Component</span>.onCompleted: <span class="name">console</span>.<span class="name">log</span>(<span class="string">&quot;Nested Completed Running!&quot;</span>)
      }
  }

</pre>
</div></div><!-- @@@completed -->
<br/>
<!-- $$$destruction -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="destruction-signal">
<td class="tblQmlFuncNode"><p>
<a name="destruction-signal"></a><span class="name">destruction</span>()</p></td></tr>
</table></div>
</div><div class="qmldoc"><p>Emitted as the object begins destruction. This can be used to undo work done in response to the <a href="qml-qtqml-component.html#completed-signal">completed()</a> signal, or other imperative code in your application.</p>
<p>The corresponding handler is <code>onDestruction</code>. It can be declared on any object. The order of running the <code>onDestruction</code> handlers is undefined.</p>
<pre class="qml">

  <span class="type">Rectangle</span> {
      <span class="name">Component</span>.onDestruction: <span class="name">console</span>.<span class="name">log</span>(<span class="string">&quot;Destruction Beginning!&quot;</span>)
      <span class="type">Rectangle</span> {
          <span class="name">Component</span>.onDestruction: <span class="name">console</span>.<span class="name">log</span>(<span class="string">&quot;Nested Destruction Beginning!&quot;</span>)
      }
  }

</pre>
<p><b>See also </b><a href="qtqml-index.html">Qt QML</a>.</p>
</div></div><!-- @@@destruction -->
<br/>
<h2>Method Documentation</h2>
<!-- $$$createObject -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="createObject-method">
<td class="tblQmlFuncNode"><p>
<a name="createObject-method"></a><span class="type">object</span> <span class="name">createObject</span>(<span class="type"><a href="qml-qtqml-qtobject.html">QtObject</a></span> <i>parent</i>, <span class="type">object</span> <i>properties</i>)</p></td></tr>
</table></div>
</div><div class="qmldoc"><p>Creates and returns an object instance of this component that will have the given <i>parent</i> and <i>properties</i>. The <i>properties</i> argument is optional. Returns null if object creation fails.</p>
<p>The object will be created in the same context as the one in which the component was created. This function will always return null when called on components which were not created in QML.</p>
<p>If you wish to create an object without setting a parent, specify <code>null</code> for the <i>parent</i> value. Note that if the returned object is to be displayed, you must provide a valid <i>parent</i> value or set the returned object's parent property, otherwise the object will not be visible.</p>
<p>If a <i>parent</i> is not provided to createObject(), a reference to the returned object must be held so that it is not destroyed by the garbage collector. This is true regardless of whether Item::parent is set afterwards, because setting the Item parent does not change object ownership. Only the graphical parent is changed.</p>
<p>As of <code>QtQuick 1.1</code>, this method accepts an optional <i>properties</i> argument that specifies a map of initial property values for the created object. These values are applied before the object creation is finalized. This is more efficient than setting property values after object creation, particularly where large sets of property values are defined, and also allows property bindings to be set up (using <a href="qml-qtqml-qt.html#binding-method">Qt.binding</a>) before the object is created.</p>
<p>The <i>properties</i> argument is specified as a map of property-value items. For example, the code below creates an object with initial <code>x</code> and <code>y</code> values of 100 and 100, respectively:</p>
<pre class="js">

  var <span class="name">component</span> = <span class="name">Qt</span>.<span class="name">createComponent</span>(<span class="string">&quot;Button.qml&quot;</span>);
  <span class="keyword">if</span> (<span class="name">component</span>.<span class="name">status</span> <span class="operator">==</span> <span class="name">Component</span>.<span class="name">Ready</span>)
      <span class="name">component</span>.<span class="name">createObject</span>(<span class="name">parent</span>, {&quot;x&quot;: <span class="number">100</span>, &quot;y&quot;: <span class="number">100</span>});

</pre>
<p>Dynamically created instances can be deleted with the <code>destroy()</code> method. See <a href="qtqml-javascript-dynamicobjectcreation.html">Dynamic QML Object Creation from JavaScript</a> for more information.</p>
<p><b>See also </b><a href="qml-qtqml-component.html#incubateObject-method">incubateObject()</a>.</p>
</div></div><!-- @@@createObject -->
<br/>
<!-- $$$errorString -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="errorString-method">
<td class="tblQmlFuncNode"><p>
<a name="errorString-method"></a><span class="type">string</span> <span class="name">errorString</span>()</p></td></tr>
</table></div>
</div><div class="qmldoc"><p>Returns a human-readable description of any error.</p>
<p>The string includes the file, location, and description of each error. If multiple errors are present, they are separated by a newline character.</p>
<p>If no errors are present, an empty string is returned.</p>
</div></div><!-- @@@errorString -->
<br/>
<!-- $$$incubateObject -->
<div class="qmlitem"><div class="qmlproto">
<div class="table"><table class="qmlname">
<tr valign="top" class="odd" id="incubateObject-method">
<td class="tblQmlFuncNode"><p>
<a name="incubateObject-method"></a><span class="type">object</span> <span class="name">incubateObject</span>(<span class="type">Item</span> <i>parent</i>, <span class="type">object</span> <i>properties</i>, <span class="type">enumeration</span> <i>mode</i>)</p></td></tr>
</table></div>
</div><div class="qmldoc"><p>Creates an incubator for an instance of this component. Incubators allow new component instances to be instantiated asynchronously and do not cause freezes in the UI.</p>
<p>The <i>parent</i> argument specifies the parent the created instance will have. Omitting the parameter or passing null will create an object with no parent. In this case, a reference to the created object must be held so that it is not destroyed by the garbage collector.</p>
<p>The <i>properties</i> argument is specified as a map of property-value items which will be set on the created object during its construction. <i>mode</i> may be Qt.Synchronous or Qt.Asynchronous, and controls whether the instance is created synchronously or asynchronously. The default is asynchronous. In some circumstances, even if Qt.Synchronous is specified, the incubator may create the object asynchronously. This happens if the component calling incubateObject() is itself being created asynchronously.</p>
<p>All three arguments are optional.</p>
<p>If successful, the method returns an incubator, otherwise null. The incubator has the following properties:</p>
<ul>
<li>status The status of the incubator. Valid values are Component.Ready, Component.Loading and Component.Error.</li>
<li>object The created object instance. Will only be available once the incubator is in the Ready status.</li>
<li>onStatusChanged Specifies a callback function to be invoked when the status changes. The status is passed as a parameter to the callback.</li>
<li>forceCompletion() Call to complete incubation synchronously.</li>
</ul>
<p>The following example demonstrates how to use an incubator:</p>
<pre class="js">

  var <span class="name">component</span> = <span class="name">Qt</span>.<span class="name">createComponent</span>(<span class="string">&quot;Button.qml&quot;</span>);

  var <span class="name">incubator</span> = <span class="name">component</span>.<span class="name">incubateObject</span>(<span class="name">parent</span>, { x: <span class="number">10</span>, y: <span class="number">10</span> });
  <span class="keyword">if</span> (<span class="name">incubator</span>.<span class="name">status</span> <span class="operator">!=</span> <span class="name">Component</span>.<span class="name">Ready</span>) {
      <span class="name">incubator</span>.<span class="name">onStatusChanged</span> <span class="operator">=</span> <span class="keyword">function</span>(<span class="name">status</span>) {
          <span class="keyword">if</span> (<span class="name">status</span> <span class="operator">==</span> <span class="name">Component</span>.<span class="name">Ready</span>) {
              <span class="name">print</span> (<span class="string">&quot;Object&quot;</span>, <span class="name">incubator</span>.<span class="name">object</span>, <span class="string">&quot;is now ready!&quot;</span>);
          }
      }
  } <span class="keyword">else</span> {
      <span class="name">print</span> (<span class="string">&quot;Object&quot;</span>, <span class="name">incubator</span>.<span class="name">object</span>, <span class="string">&quot;is ready immediately!&quot;</span>);
  }

</pre>
<p>Dynamically created instances can be deleted with the <code>destroy()</code> method. See <a href="qtqml-javascript-dynamicobjectcreation.html">Dynamic QML Object Creation from JavaScript</a> for more information.</p>
<p><b>See also </b><a href="qml-qtqml-component.html#createObject-method">createObject()</a>.</p>
</div></div><!-- @@@incubateObject -->
<br/>
        </div>
       </div>
   </div>
   </div>
</div>
<div class="footer">
   <p>
   <acronym title="Copyright">&copy;</acronym> 2017 The Qt Company Ltd.
   Documentation contributions included herein are the copyrights of
   their respective owners.<br>    The documentation provided herein is licensed under the terms of the    <a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation    License version 1.3</a> as published by the Free Software Foundation.<br>    Qt and respective logos are trademarks of The Qt Company Ltd.     in Finland and/or other countries worldwide. All other trademarks are property
   of their respective owners. </p>
</div>
</body>
</html>