/usr/share/qt5/doc/qtqml/qqmlexpression.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 | <?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" />
<!-- qqmlexpression.cpp -->
<title>QQmlExpression 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>QQmlExpression</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-functions">Public Functions</a></li>
<li class="level1"><a href="#signals">Signals</a></li>
<li class="level1"><a href="#details">Detailed Description</a></li>
</ul>
</div>
<h1 class="title">QQmlExpression Class</h1>
<!-- $$$QQmlExpression-brief -->
<p>The QQmlExpression class evaluates JavaScript in a QML context. <a href="#details">More...</a></p>
<!-- @@@QQmlExpression -->
<table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> Header:</td><td class="memItemRight bottomAlign"> </b><tt><span class="preprocessor">#include <QQmlExpression></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></table><ul>
<li><a href="qqmlexpression-members.html">List of all members, including inherited members</a></li>
</ul>
<a name="public-functions"></a>
<h2>Public Functions</h2>
<table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qqmlexpression.html#QQmlExpression">QQmlExpression</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qqmlexpression.html#QQmlExpression-2">QQmlExpression</a></b>(QQmlContext *<i> ctxt</i>, QObject *<i> scope</i>, const QString &<i> expression</i>, QObject *<i> parent</i> = 0)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qqmlexpression.html#QQmlExpression-3">QQmlExpression</a></b>(const QQmlScriptString &<i> script</i>, QQmlContext *<i> ctxt</i> = 0, QObject *<i> scope</i> = 0, QObject *<i> parent</i> = 0)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual </td><td class="memItemRight bottomAlign"><b><a href="qqmlexpression.html#dtor.QQmlExpression">~QQmlExpression</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qqmlexpression.html#clearError">clearError</a></b>()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qqmlexpression.html#columnNumber">columnNumber</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QQmlContext * </td><td class="memItemRight bottomAlign"><b><a href="qqmlexpression.html#context">context</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QQmlEngine * </td><td class="memItemRight bottomAlign"><b><a href="qqmlexpression.html#engine">engine</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QQmlError </td><td class="memItemRight bottomAlign"><b><a href="qqmlexpression.html#error">error</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QVariant </td><td class="memItemRight bottomAlign"><b><a href="qqmlexpression.html#evaluate">evaluate</a></b>(bool *<i> valueIsUndefined</i> = 0)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QString </td><td class="memItemRight bottomAlign"><b><a href="qqmlexpression.html#expression">expression</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qqmlexpression.html#hasError">hasError</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> int </td><td class="memItemRight bottomAlign"><b><a href="qqmlexpression.html#lineNumber">lineNumber</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qqmlexpression.html#notifyOnValueChanged">notifyOnValueChanged</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QObject * </td><td class="memItemRight bottomAlign"><b><a href="qqmlexpression.html#scopeObject">scopeObject</a></b>() const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qqmlexpression.html#setExpression">setExpression</a></b>(const QString &<i> expression</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qqmlexpression.html#setNotifyOnValueChanged">setNotifyOnValueChanged</a></b>(bool<i> notifyOnChange</i>)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qqmlexpression.html#setSourceLocation">setSourceLocation</a></b>(const QString &<i> url</i>, int<i> line</i>, int<i> column</i> = 0)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QString </td><td class="memItemRight bottomAlign"><b><a href="qqmlexpression.html#sourceFile">sourceFile</a></b>() const</td></tr>
</table>
<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="qqmlexpression.html#valueChanged">valueChanged</a></b>()</td></tr>
</table>
<a name="details"></a>
<!-- $$$QQmlExpression-description -->
<div class="descr">
<h2>Detailed Description</h2>
<p>The QQmlExpression class evaluates JavaScript in a QML context.</p>
<p>For example, given a file <tt>main.qml</tt> like this:</p>
<pre class="qml">import QtQuick 2.0
<span class="type">Item</span> {
<span class="name">width</span>: <span class="number">200</span>; <span class="name">height</span>: <span class="number">200</span>
}</pre>
<p>The following code evaluates a JavaScript expression in the context of the above QML:</p>
<pre class="cpp"><span class="type"><a href="qqmlengine.html">QQmlEngine</a></span> <span class="operator">*</span>engine <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qqmlengine.html">QQmlEngine</a></span>;
<span class="type"><a href="qqmlcomponent.html">QQmlComponent</a></span> component(engine<span class="operator">,</span> <span class="type">QUrl</span><span class="operator">::</span>fromLocalFile(<span class="string">"main.qml"</span>));
<span class="type">QObject</span> <span class="operator">*</span>myObject <span class="operator">=</span> component<span class="operator">.</span>create();
<span class="type">QQmlExpression</span> <span class="operator">*</span>expr <span class="operator">=</span> <span class="keyword">new</span> <span class="type">QQmlExpression</span>(engine<span class="operator">-</span><span class="operator">></span>rootContext()<span class="operator">,</span> myObject<span class="operator">,</span> <span class="string">"width * 2"</span>);
<span class="type">int</span> result <span class="operator">=</span> expr<span class="operator">-</span><span class="operator">></span><a href="qqmlexpression.html#evaluate">evaluate</a>()<span class="operator">.</span>toInt(); <span class="comment">// result = 400</span></pre>
<p>Note that the Qt Quick 1 version is called QDeclarativeExpression.</p>
</div>
<!-- @@@QQmlExpression -->
<div class="func">
<h2>Member Function Documentation</h2>
<!-- $$$QQmlExpression[overload1]$$$QQmlExpression -->
<h3 class="fn"><a name="QQmlExpression"></a>QQmlExpression::<span class="name">QQmlExpression</span>()</h3>
<p>Create an invalid <a href="qqmlexpression.html">QQmlExpression</a>.</p>
<p>As the expression will not have an associated <a href="qqmlcontext.html">QQmlContext</a>, this will be a null expression object and its value will always be an invalid QVariant.</p>
<!-- @@@QQmlExpression -->
<!-- $$$QQmlExpression$$$QQmlExpressionQQmlContext*QObject*constQString&QObject* -->
<h3 class="fn"><a name="QQmlExpression-2"></a>QQmlExpression::<span class="name">QQmlExpression</span>(<span class="type"><a href="qqmlcontext.html">QQmlContext</a></span> *<i> ctxt</i>, <span class="type">QObject</span> *<i> scope</i>, const <span class="type">QString</span> &<i> expression</i>, <span class="type">QObject</span> *<i> parent</i> = 0)</h3>
<p>Create a <a href="qqmlexpression.html">QQmlExpression</a> object that is a child of <i>parent</i>.</p>
<p>The <i>expression</i> JavaScript will be executed in the <i>ctxt</i> <a href="qqmlcontext.html">QQmlContext</a>. If specified, the <i>scope</i> object's properties will also be in scope during the expression's execution.</p>
<!-- @@@QQmlExpression -->
<!-- $$$QQmlExpression$$$QQmlExpressionconstQQmlScriptString&QQmlContext*QObject*QObject* -->
<h3 class="fn"><a name="QQmlExpression-3"></a>QQmlExpression::<span class="name">QQmlExpression</span>(const <span class="type"><a href="qqmlscriptstring.html">QQmlScriptString</a></span> &<i> script</i>, <span class="type"><a href="qqmlcontext.html">QQmlContext</a></span> *<i> ctxt</i> = 0, <span class="type">QObject</span> *<i> scope</i> = 0, <span class="type">QObject</span> *<i> parent</i> = 0)</h3>
<p>Create a <a href="qqmlexpression.html">QQmlExpression</a> object that is a child of <i>parent</i>.</p>
<p>The <i>script</i> provides the expression to be evaluated, the context to evaluate it in, and the scope object to evaluate it with. If provided, <i>ctxt</i> and <i>scope</i> will override the context and scope object provided by <i>script</i>.</p>
<p><b>See also </b><a href="qqmlscriptstring.html">QQmlScriptString</a>.</p>
<!-- @@@QQmlExpression -->
<!-- $$$~QQmlExpression[overload1]$$$~QQmlExpression -->
<h3 class="fn"><a name="dtor.QQmlExpression"></a>QQmlExpression::<span class="name">~QQmlExpression</span>()<tt> [virtual]</tt></h3>
<p>Destroy the <a href="qqmlexpression.html">QQmlExpression</a> instance.</p>
<!-- @@@~QQmlExpression -->
<!-- $$$clearError[overload1]$$$clearError -->
<h3 class="fn"><a name="clearError"></a><span class="type">void</span> QQmlExpression::<span class="name">clearError</span>()</h3>
<p>Clear any expression errors. Calls to <a href="qqmlexpression.html#hasError">hasError</a>() following this will return false.</p>
<p><b>See also </b><a href="qqmlexpression.html#hasError">hasError</a>() and <a href="qqmlexpression.html#error">error</a>().</p>
<!-- @@@clearError -->
<!-- $$$columnNumber[overload1]$$$columnNumber -->
<h3 class="fn"><a name="columnNumber"></a><span class="type">int</span> QQmlExpression::<span class="name">columnNumber</span>() const</h3>
<p>Returns the source file column number for this expression. The source location must have been previously set by calling <a href="qqmlexpression.html#setSourceLocation">setSourceLocation</a>().</p>
<!-- @@@columnNumber -->
<!-- $$$context[overload1]$$$context -->
<h3 class="fn"><a name="context"></a><span class="type"><a href="qqmlcontext.html">QQmlContext</a></span> * QQmlExpression::<span class="name">context</span>() const</h3>
<p>Returns the <a href="qqmlcontext.html">QQmlContext</a> this expression is associated with, or 0 if there is no association or the <a href="qqmlcontext.html">QQmlContext</a> has been destroyed.</p>
<!-- @@@context -->
<!-- $$$engine[overload1]$$$engine -->
<h3 class="fn"><a name="engine"></a><span class="type"><a href="qqmlengine.html">QQmlEngine</a></span> * QQmlExpression::<span class="name">engine</span>() const</h3>
<p>Returns the <a href="qqmlengine.html">QQmlEngine</a> this expression is associated with, or 0 if there is no association or the <a href="qqmlengine.html">QQmlEngine</a> has been destroyed.</p>
<!-- @@@engine -->
<!-- $$$error[overload1]$$$error -->
<h3 class="fn"><a name="error"></a><span class="type"><a href="qqmlerror.html">QQmlError</a></span> QQmlExpression::<span class="name">error</span>() const</h3>
<p>Return any error from the last call to <a href="qqmlexpression.html#evaluate">evaluate</a>(). If there was no error, this returns an invalid <a href="qqmlerror.html">QQmlError</a> instance.</p>
<p><b>See also </b><a href="qqmlexpression.html#hasError">hasError</a>() and <a href="qqmlexpression.html#clearError">clearError</a>().</p>
<!-- @@@error -->
<!-- $$$evaluate[overload1]$$$evaluatebool* -->
<h3 class="fn"><a name="evaluate"></a><span class="type">QVariant</span> QQmlExpression::<span class="name">evaluate</span>(<span class="type">bool</span> *<i> valueIsUndefined</i> = 0)</h3>
<p>Evaulates the expression, returning the result of the evaluation, or an invalid QVariant if the expression is invalid or has an error.</p>
<p><i>valueIsUndefined</i> is set to true if the expression resulted in an undefined value.</p>
<p><b>See also </b><a href="qqmlexpression.html#hasError">hasError</a>() and <a href="qqmlexpression.html#error">error</a>().</p>
<!-- @@@evaluate -->
<!-- $$$expression[overload1]$$$expression -->
<h3 class="fn"><a name="expression"></a><span class="type">QString</span> QQmlExpression::<span class="name">expression</span>() const</h3>
<p>Returns the expression string.</p>
<p><b>See also </b><a href="qqmlexpression.html#setExpression">setExpression</a>().</p>
<!-- @@@expression -->
<!-- $$$hasError[overload1]$$$hasError -->
<h3 class="fn"><a name="hasError"></a><span class="type">bool</span> QQmlExpression::<span class="name">hasError</span>() const</h3>
<p>Returns true if the last call to <a href="qqmlexpression.html#evaluate">evaluate</a>() resulted in an error, otherwise false.</p>
<p><b>See also </b><a href="qqmlexpression.html#error">error</a>() and <a href="qqmlexpression.html#clearError">clearError</a>().</p>
<!-- @@@hasError -->
<!-- $$$lineNumber[overload1]$$$lineNumber -->
<h3 class="fn"><a name="lineNumber"></a><span class="type">int</span> QQmlExpression::<span class="name">lineNumber</span>() const</h3>
<p>Returns the source file line number for this expression. The source location must have been previously set by calling <a href="qqmlexpression.html#setSourceLocation">setSourceLocation</a>().</p>
<!-- @@@lineNumber -->
<!-- $$$notifyOnValueChanged[overload1]$$$notifyOnValueChanged -->
<h3 class="fn"><a name="notifyOnValueChanged"></a><span class="type">bool</span> QQmlExpression::<span class="name">notifyOnValueChanged</span>() const</h3>
<p>Returns true if the <a href="qqmlexpression.html#valueChanged">valueChanged</a>() signal is emitted when the expression's evaluated value changes.</p>
<p><b>See also </b><a href="qqmlexpression.html#setNotifyOnValueChanged">setNotifyOnValueChanged</a>().</p>
<!-- @@@notifyOnValueChanged -->
<!-- $$$scopeObject[overload1]$$$scopeObject -->
<h3 class="fn"><a name="scopeObject"></a><span class="type">QObject</span> * QQmlExpression::<span class="name">scopeObject</span>() const</h3>
<p>Returns the expression's scope object, if provided, otherwise 0.</p>
<p>In addition to data provided by the expression's <a href="qqmlcontext.html">QQmlContext</a>, the scope object's properties are also in scope during the expression's evaluation.</p>
<!-- @@@scopeObject -->
<!-- $$$setExpression[overload1]$$$setExpressionconstQString& -->
<h3 class="fn"><a name="setExpression"></a><span class="type">void</span> QQmlExpression::<span class="name">setExpression</span>(const <span class="type">QString</span> &<i> expression</i>)</h3>
<p>Set the expression to <i>expression</i>.</p>
<p><b>See also </b><a href="qqmlexpression.html#expression">expression</a>().</p>
<!-- @@@setExpression -->
<!-- $$$setNotifyOnValueChanged[overload1]$$$setNotifyOnValueChangedbool -->
<h3 class="fn"><a name="setNotifyOnValueChanged"></a><span class="type">void</span> QQmlExpression::<span class="name">setNotifyOnValueChanged</span>(<span class="type">bool</span><i> notifyOnChange</i>)</h3>
<p>Sets whether the <a href="qqmlexpression.html#valueChanged">valueChanged</a>() signal is emitted when the expression's evaluated value changes.</p>
<p>If <i>notifyOnChange</i> is true, the <a href="qqmlexpression.html">QQmlExpression</a> will monitor properties involved in the expression's evaluation, and emit <a href="qqmlexpression.html#valueChanged">QQmlExpression::valueChanged</a>() if they have changed. This allows an application to ensure that any value associated with the result of the expression remains up to date.</p>
<p>If <i>notifyOnChange</i> is false (default), the <a href="qqmlexpression.html">QQmlExpression</a> will not montitor properties involved in the expression's evaluation, and <a href="qqmlexpression.html#valueChanged">QQmlExpression::valueChanged</a>() will never be emitted. This is more efficient if an application wants a "one off" evaluation of the expression.</p>
<p><b>See also </b><a href="qqmlexpression.html#notifyOnValueChanged">notifyOnValueChanged</a>().</p>
<!-- @@@setNotifyOnValueChanged -->
<!-- $$$setSourceLocation[overload1]$$$setSourceLocationconstQString&intint -->
<h3 class="fn"><a name="setSourceLocation"></a><span class="type">void</span> QQmlExpression::<span class="name">setSourceLocation</span>(const <span class="type">QString</span> &<i> url</i>, <span class="type">int</span><i> line</i>, <span class="type">int</span><i> column</i> = 0)</h3>
<p>Set the location of this expression to <i>line</i> of <i>url</i>. This information is used by the script engine.</p>
<!-- @@@setSourceLocation -->
<!-- $$$sourceFile[overload1]$$$sourceFile -->
<h3 class="fn"><a name="sourceFile"></a><span class="type">QString</span> QQmlExpression::<span class="name">sourceFile</span>() const</h3>
<p>Returns the source file URL for this expression. The source location must have been previously set by calling <a href="qqmlexpression.html#setSourceLocation">setSourceLocation</a>().</p>
<!-- @@@sourceFile -->
<!-- $$$valueChanged[overload1]$$$valueChanged -->
<h3 class="fn"><a name="valueChanged"></a><span class="type">void</span> QQmlExpression::<span class="name">valueChanged</span>()<tt> [signal]</tt></h3>
<p>Emitted each time the expression value changes from the last time it was evaluated. The expression must have been evaluated at least once (by calling <a href="qqmlexpression.html#evaluate">QQmlExpression::evaluate</a>()) before this signal will be emitted.</p>
<!-- @@@valueChanged -->
</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>
|