Sophie

Sophie

distrib > Mageia > 4 > i586 > by-pkgid > 28b9e36e96ce34b2567ae5b47a27b2c5 > files > 593

python-qt4-doc-4.10.3-3.mga4.noarch.rpm

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html><head><title>QDeclarativeExpression Class Reference</title><style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }
td.postheader { font-family: sans-serif }
tr.address { font-family: sans-serif }
body { background: #ffffff; color: black; }
</style></head><body><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr /><td align="left" valign="top" width="32"><img align="left" border="0" height="32" src="images/rb-logo.png" width="32" /></td><td width="1">&#160;&#160;</td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a>&#160;&#183; <a href="classes.html"><font color="#004faf">All Classes</font></a>&#160;&#183; <a href="modules.html"><font color="#004faf">Modules</font></a></td></table><h1 align="center">QDeclarativeExpression Class Reference<br /><sup><sup>[<a href="qtdeclarative.html">QtDeclarative</a> module]</sup></sup></h1><p>The QDeclarativeExpression class evaluates JavaScript in a QML
context. <a href="#details">More...</a></p>

<p>Inherits <a href="qobject.html">QObject</a>.</p><h3>Methods</h3><ul><li><div class="fn" /><b><a href="qdeclarativeexpression.html#QDeclarativeExpression">__init__</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qdeclarativeexpression.html#QDeclarativeExpression-2">__init__</a></b> (<i>self</i>, QDeclarativeContext, QObject, QString, QObject&#160;<i>parent</i>&#160;=&#160;None)</li><li><div class="fn" /><b><a href="qdeclarativeexpression.html#clearError">clearError</a></b> (<i>self</i>)</li><li><div class="fn" />QDeclarativeContext <b><a href="qdeclarativeexpression.html#context">context</a></b> (<i>self</i>)</li><li><div class="fn" />QDeclarativeEngine <b><a href="qdeclarativeexpression.html#engine">engine</a></b> (<i>self</i>)</li><li><div class="fn" />QDeclarativeError <b><a href="qdeclarativeexpression.html#error">error</a></b> (<i>self</i>)</li><li><div class="fn" />(QVariant, bool&#160;<i>valueIsUndefined</i>) <b><a href="qdeclarativeexpression.html#evaluate">evaluate</a></b> (<i>self</i>)</li><li><div class="fn" />QString <b><a href="qdeclarativeexpression.html#expression">expression</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qdeclarativeexpression.html#hasError">hasError</a></b> (<i>self</i>)</li><li><div class="fn" />int <b><a href="qdeclarativeexpression.html#lineNumber">lineNumber</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qdeclarativeexpression.html#notifyOnValueChanged">notifyOnValueChanged</a></b> (<i>self</i>)</li><li><div class="fn" />QObject <b><a href="qdeclarativeexpression.html#scopeObject">scopeObject</a></b> (<i>self</i>)</li><li><div class="fn" /><b><a href="qdeclarativeexpression.html#setExpression">setExpression</a></b> (<i>self</i>, QString)</li><li><div class="fn" /><b><a href="qdeclarativeexpression.html#setNotifyOnValueChanged">setNotifyOnValueChanged</a></b> (<i>self</i>, bool)</li><li><div class="fn" /><b><a href="qdeclarativeexpression.html#setSourceLocation">setSourceLocation</a></b> (<i>self</i>, QString&#160;<i>fileName</i>, int&#160;<i>line</i>)</li><li><div class="fn" />QString <b><a href="qdeclarativeexpression.html#sourceFile">sourceFile</a></b> (<i>self</i>)</li></ul><h3>Qt Signals</h3><ul><li><div class="fn" />void <b><a href="qdeclarativeexpression.html#valueChanged">valueChanged</a></b> ()</li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>The QDeclarativeExpression 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 1.0

 <span class="type"><a href="qml-item.html">Item</a></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="qdeclarativeengine.html">QDeclarativeEngine</a></span> <span class="operator">*</span>engine <span class="operator">=</span> <span class="keyword">new</span> <span class="type"><a href="qdeclarativeengine.html">QDeclarativeEngine</a></span>;
 <span class="type"><a href="qdeclarativecomponent.html">QDeclarativeComponent</a></span> component(engine<span class="operator">,</span> <span class="type"><a href="qurl.html">QUrl</a></span><span class="operator">.</span>fromLocalFile(<span class="string">"main.qml"</span>));

 <span class="type"><a href="qobject.html">QObject</a></span> <span class="operator">*</span>myObject <span class="operator">=</span> component<span class="operator">.</span>create();
 <span class="type">QDeclarativeExpression</span> <span class="operator">*</span>expr <span class="operator">=</span> <span class="keyword">new</span> <span class="type">QDeclarativeExpression</span>(engine<span class="operator">-</span><span class="operator">&gt;</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">&gt;</span><a href="qdeclarativeexpression.html#evaluate">evaluate</a>()<span class="operator">.</span>toInt();  <span class="comment">// result = 400</span>
</pre><hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QDeclarativeExpression" />QDeclarativeExpression.__init__ (<i>self</i>)</h3><p>Create an invalid <a href="qdeclarativeexpression.html">QDeclarativeExpression</a>.</p>
<p>As the expression will not have an associated <a href="qdeclarativecontext.html">QDeclarativeContext</a>, this will be a
null expression object and its value will always be an invalid
<a href="qvariant.html">QVariant</a>.</p>


<h3 class="fn"><a name="QDeclarativeExpression-2" />QDeclarativeExpression.__init__ (<i>self</i>, <a href="qdeclarativecontext.html">QDeclarativeContext</a>, <a href="qobject.html">QObject</a>, QString, <a href="qobject.html">QObject</a>&#160;<i>parent</i>&#160;=&#160;None)</h3><p>The <i>parent</i> argument, if not None, causes <i>self</i> to be owned by Qt instead of PyQt.</p><p>Create a <a href="qdeclarativeexpression.html">QDeclarativeExpression</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="qdeclarativecontext.html">QDeclarativeContext</a>. If specified,
the <i>scope</i> object's properties will also be in scope during
the expression's execution.</p>


<h3 class="fn"><a name="clearError" />QDeclarativeExpression.clearError (<i>self</i>)</h3><p>Clear any expression errors. Calls to <a href="qdeclarativeexpression.html#hasError">hasError</a>() following
this will return false.</p>
<p><b>See also</b> <a href="qdeclarativeexpression.html#hasError">hasError</a>() and <a href="qdeclarativeexpression.html#error">error</a>().</p>


<h3 class="fn"><a name="context" /><a href="qdeclarativecontext.html">QDeclarativeContext</a> QDeclarativeExpression.context (<i>self</i>)</h3><p>Returns the <a href="qdeclarativecontext.html">QDeclarativeContext</a> this expression
is associated with, or 0 if there is no association or the <a href="qdeclarativecontext.html">QDeclarativeContext</a> has been
destroyed.</p>


<h3 class="fn"><a name="engine" /><a href="qdeclarativeengine.html">QDeclarativeEngine</a> QDeclarativeExpression.engine (<i>self</i>)</h3><p>Returns the <a href="qdeclarativeengine.html">QDeclarativeEngine</a> this expression is
associated with, or 0 if there is no association or the <a href="qdeclarativeengine.html">QDeclarativeEngine</a> has been
destroyed.</p>


<h3 class="fn"><a name="error" /><a href="qdeclarativeerror.html">QDeclarativeError</a> QDeclarativeExpression.error (<i>self</i>)</h3><p>Return any error from the last call to <a href="qdeclarativeexpression.html#evaluate">evaluate</a>(). If there was
no error, this returns an invalid <a href="qdeclarativeerror.html">QDeclarativeError</a> instance.</p>
<p><b>See also</b> <a href="qdeclarativeexpression.html#hasError">hasError</a>() and <a href="qdeclarativeexpression.html#clearError">clearError</a>().</p>


<h3 class="fn"><a name="evaluate" />(QVariant, bool&#160;<i>valueIsUndefined</i>) QDeclarativeExpression.evaluate (<i>self</i>)</h3><p>Evaulates the expression, returning the result of the
evaluation, or an invalid <a href="qvariant.html">QVariant</a> 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="qdeclarativeexpression.html#hasError">hasError</a>() and <a href="qdeclarativeexpression.html#error">error</a>().</p>


<h3 class="fn"><a name="expression" />QString QDeclarativeExpression.expression (<i>self</i>)</h3><p>Returns the expression string.</p>
<p><b>See also</b> <a href="qdeclarativeexpression.html#setExpression">setExpression</a>().</p>


<h3 class="fn"><a name="hasError" />bool QDeclarativeExpression.hasError (<i>self</i>)</h3><p>Returns true if the last call to <a href="qdeclarativeexpression.html#evaluate">evaluate</a>() resulted in
an error, otherwise false.</p>
<p><b>See also</b> <a href="qdeclarativeexpression.html#error">error</a>() and <a href="qdeclarativeexpression.html#clearError">clearError</a>().</p>


<h3 class="fn"><a name="lineNumber" />int QDeclarativeExpression.lineNumber (<i>self</i>)</h3><p>Returns the source file line number for this expression. The
source location must have been previously set by calling <a href="qdeclarativeexpression.html#setSourceLocation">setSourceLocation</a>().</p>


<h3 class="fn"><a name="notifyOnValueChanged" />bool QDeclarativeExpression.notifyOnValueChanged (<i>self</i>)</h3><p>Returns true if the <a href="qdeclarativeexpression.html#valueChanged">valueChanged</a>()
signal is emitted when the expression's evaluated value
changes.</p>
<p><b>See also</b> <a href="qdeclarativeexpression.html#setNotifyOnValueChanged">setNotifyOnValueChanged</a>().</p>


<h3 class="fn"><a name="scopeObject" /><a href="qobject.html">QObject</a> QDeclarativeExpression.scopeObject (<i>self</i>)</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="qdeclarativecontext.html">QDeclarativeContext</a>, the scope
object's properties are also in scope during the expression's
evaluation.</p>


<h3 class="fn"><a name="setExpression" />QDeclarativeExpression.setExpression (<i>self</i>, QString)</h3><p>Set the expression to <i>expression</i>.</p>
<p><b>See also</b> <a href="qdeclarativeexpression.html#expression">expression</a>().</p>


<h3 class="fn"><a name="setNotifyOnValueChanged" />QDeclarativeExpression.setNotifyOnValueChanged (<i>self</i>, bool)</h3><p>Sets whether the <a href="qdeclarativeexpression.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="qdeclarativeexpression.html">QDeclarativeExpression</a> will
monitor properties involved in the expression's evaluation, and
emit <a href="qdeclarativeexpression.html#valueChanged">QDeclarativeExpression.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="qdeclarativeexpression.html">QDeclarativeExpression</a> will not
montitor properties involved in the expression's evaluation, and
<a href="qdeclarativeexpression.html#valueChanged">QDeclarativeExpression.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="qdeclarativeexpression.html#notifyOnValueChanged">notifyOnValueChanged</a>().</p>


<h3 class="fn"><a name="setSourceLocation" />QDeclarativeExpression.setSourceLocation (<i>self</i>, QString&#160;<i>fileName</i>, int&#160;<i>line</i>)</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>


<h3 class="fn"><a name="sourceFile" />QString QDeclarativeExpression.sourceFile (<i>self</i>)</h3><p>Returns the source file URL for this expression. The source
location must have been previously set by calling <a href="qdeclarativeexpression.html#setSourceLocation">setSourceLocation</a>().</p>


<hr /><h2>Qt Signal Documentation</h2><h3 class="fn"><a name="valueChanged" />void valueChanged ()</h3><p>This is the default overload of this signal.</p><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="qdeclarativeexpression.html#evaluate">QDeclarativeExpression.evaluate</a>())
before this signal will be emitted.</p>
<address><hr /><div align="center"><table border="0" cellspacing="0" width="100%"><tr class="address"><td align="left" width="25%">PyQt&#160;4.10.3 for X11</td><td align="center" width="50%">Copyright &#169; <a href="http://www.riverbankcomputing.com">Riverbank&#160;Computing&#160;Ltd</a> and <a href="http://www.qtsoftware.com">Nokia</a> 2012</td><td align="right" width="25%">Qt&#160;4.8.5</td></tr></table></div></address></body></html>