This file is indexed.

/usr/share/qt5/doc/qtqml/qtjavascript.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
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- qtjavascript.qdoc -->
  <title>Making Applications Scriptable | 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 >Making Applications Scriptable</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="#scripting-classes">Scripting Classes</a></li>
<li class="level1"><a href="#basic-usage">Basic Usage</a></li>
<li class="level1"><a href="#making-a-qobject-available-to-the-script-engine">Making a QObject Available to the Script Engine</a></li>
</ul>
</div>
<div class="sidebar-content" id="sidebar-content"></div></div>
<h1 class="title">Making Applications Scriptable</h1>
<span class="subtitle"></span>
<!-- $$$qtjavascript.html-description -->
<div class="descr"> <a name="details"></a>
<p>Qt provides support for application scripting with JavaScript. The following guides and references cover aspects of programming with JavaScript and Qt.</p>
<a name="scripting-classes"></a>
<h2 id="scripting-classes">Scripting Classes</h2>
<p>The following classes add scripting capabilities to Qt applications.</p>
<div class="table"><table class="annotated">
<tr class="odd topAlign"><td class="tblName"><p><a href="qjsengine.html">QJSEngine</a></p></td><td class="tblDescr"><p>Environment for evaluating JavaScript code</p></td></tr>
<tr class="even topAlign"><td class="tblName"><p><a href="qjsvalue.html">QJSValue</a></p></td><td class="tblDescr"><p>Acts as a container for Qt/JavaScript data types</p></td></tr>
<tr class="odd topAlign"><td class="tblName"><p><a href="qjsvalueiterator.html">QJSValueIterator</a></p></td><td class="tblDescr"><p>Java-style iterator for QJSValue</p></td></tr>
</table></div>
<a name="basic-usage"></a>
<h2 id="basic-usage">Basic Usage</h2>
<p>To evaluate script code, you create a <a href="qjsengine.html">QJSEngine</a> and call its evaluate() function, passing the script code (text) to evaluate as argument.</p>
<pre class="cpp">

  <span class="type"><a href="qjsengine.html">QJSEngine</a></span> engine;
  <a href="../qtcore/qtglobal.html#qDebug">qDebug</a>() <span class="operator">&lt;</span><span class="operator">&lt;</span> <span class="string">&quot;the magic number is:&quot;</span> <span class="operator">&lt;</span><span class="operator">&lt;</span> engine<span class="operator">.</span>evaluate(<span class="string">&quot;1 + 2&quot;</span>)<span class="operator">.</span>toNumber();

</pre>
<p>The return value will be the result of the evaluation (represented as a <a href="qjsvalue.html">QJSValue</a> object); this can be converted to standard C++ and Qt types.</p>
<p>Custom properties can be made available to scripts by registering them with the script engine. This is most easily done by setting properties of the script engine's <i>Global Object</i>:</p>
<pre class="cpp">

  engine<span class="operator">.</span>globalObject()<span class="operator">.</span>setProperty(<span class="string">&quot;foo&quot;</span><span class="operator">,</span> <span class="number">123</span>);
  <a href="../qtcore/qtglobal.html#qDebug">qDebug</a>() <span class="operator">&lt;</span><span class="operator">&lt;</span> <span class="string">&quot;foo times two is:&quot;</span> <span class="operator">&lt;</span><span class="operator">&lt;</span> engine<span class="operator">.</span>evaluate(<span class="string">&quot;foo * 2&quot;</span>)<span class="operator">.</span>toNumber();

</pre>
<p>This places the properties in the script environment, thus making them available to script code.</p>
<a name="making-a-qobject-available-to-the-script-engine"></a>
<h2 id="making-a-qobject-available-to-the-script-engine">Making a QObject Available to the Script Engine</h2>
<p>Any <a href="../qtcore/qobject.html">QObject</a>-based instance can be made available for use with scripts.</p>
<p>When a <a href="../qtcore/qobject.html">QObject</a> is passed to the <a href="qjsengine.html#newQObject">QJSEngine::newQObject</a>() function, a Qt Script wrapper object is created that can be used to make the <a href="../qtcore/qobject.html">QObject</a>'s signals, slots, properties, and child objects available to scripts.</p>
<p>Here's an example of making an instance of a <a href="../qtcore/qobject.html">QObject</a> subclass available to script code under the name <code>&quot;myObject&quot;</code>:</p>
<pre class="cpp">

  <span class="type"><a href="qjsengine.html">QJSEngine</a></span> engine;
  <span class="type"><a href="../qtcore/qobject.html">QObject</a></span> <span class="operator">*</span>someObject <span class="operator">=</span> <span class="keyword">new</span> MyObject;
  <span class="type"><a href="qjsvalue.html">QJSValue</a></span> objectValue <span class="operator">=</span> engine<span class="operator">.</span>newQObject(someObject);
  engine<span class="operator">.</span>globalObject()<span class="operator">.</span>setProperty(<span class="string">&quot;myObject&quot;</span><span class="operator">,</span> objectValue);

</pre>
<p>This will create a global variable called <code>myObject</code> in the script environment. The variable serves as a proxy to the underlying C++ object. Note that the name of the script variable can be anything; i.e&#x2e;, it is not dependent upon <a href="../qtcore/qobject.html#objectName-prop">QObject::objectName</a>().</p>
</div>
<!-- @@@qtjavascript.html -->
        </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>