diff options
author | Kent Hansen <kent.hansen@nokia.com> | 2010-01-12 10:03:50 +0100 |
---|---|---|
committer | Kent Hansen <kent.hansen@nokia.com> | 2010-01-12 10:05:49 +0100 |
commit | 2efba0002d26b584c771aa9260e6d699e5ff8da3 (patch) | |
tree | 9fd8c791dd4029d406f20c29b281471737940a2a | |
parent | 8b56ffee8bb4ec0c56c2c05ccc1e088f6d9ae8a8 (diff) | |
download | qt4-tools-2efba0002d26b584c771aa9260e6d699e5ff8da3.tar.gz |
doc: update snippets for QtScript function expressions
With the JSC-based back-end it's necessary to wrap the function
in parentheses.
Task-number: QTBUG-6644
-rw-r--r-- | doc/src/snippets/code/doc_src_qtscript.qdoc | 6 | ||||
-rw-r--r-- | doc/src/snippets/code/src_script_qscriptengine.cpp | 2 |
2 files changed, 4 insertions, 4 deletions
diff --git a/doc/src/snippets/code/doc_src_qtscript.qdoc b/doc/src/snippets/code/doc_src_qtscript.qdoc index 00dd7161b9..a33a98245e 100644 --- a/doc/src/snippets/code/doc_src_qtscript.qdoc +++ b/doc/src/snippets/code/doc_src_qtscript.qdoc @@ -513,7 +513,7 @@ int main(int argc, char **argv) //! [47] QScriptEngine eng; QLineEdit *edit = new QLineEdit(...); -QScriptValue handler = eng.evaluate("function(text) { print('text was changed to', text); }"); +QScriptValue handler = eng.evaluate("(function(text) { print('text was changed to', text); })"); qScriptConnect(edit, SIGNAL(textChanged(const QString &)), QScriptValue(), handler); //! [47] @@ -521,7 +521,7 @@ qScriptConnect(edit, SIGNAL(textChanged(const QString &)), QScriptValue(), handl QLineEdit *edit1 = new QLineEdit(...); QLineEdit *edit2 = new QLineEdit(...); -QScriptValue handler = eng.evaluate("function() { print('I am', this.name); }"); +QScriptValue handler = eng.evaluate("(function() { print('I am', this.name); })"); QScriptValue obj1 = eng.newObject(); obj1.setProperty("name", "the walrus"); QScriptValue obj2 = eng.newObject(); @@ -790,7 +790,7 @@ QScriptValue counter_hybrid(QScriptContext *ctx, QScriptEngine *eng) { QScriptValue act = ctx->activationObject(); act.setProperty("count", 0); - return eng->evaluate("function() { return count++; }"); + return eng->evaluate("(function() { return count++; })"); } //! [74] diff --git a/doc/src/snippets/code/src_script_qscriptengine.cpp b/doc/src/snippets/code/src_script_qscriptengine.cpp index c82eb658a1..f0165fd713 100644 --- a/doc/src/snippets/code/src_script_qscriptengine.cpp +++ b/doc/src/snippets/code/src_script_qscriptengine.cpp @@ -46,7 +46,7 @@ QScriptValue three = myEngine.evaluate("1 + 2"); //! [1] -QScriptValue fun = myEngine.evaluate("function(a, b) { return a + b; }"); +QScriptValue fun = myEngine.evaluate("(function(a, b) { return a + b; })"); QScriptValueList args; args << 1 << 2; QScriptValue threeAgain = fun.call(QScriptValue(), args); |