以下成員源於類 QScriptEngine 已過時。 提供它們是為使舊源代碼能繼續工作。強烈建議不要在新代碼中使用它們。
(obsolete)
bool
|
canEvaluate (const QString & program ) const |
(obsolete)
QScriptValue
|
qScriptValueFromValue (QScriptEngine * engine , const T & value ) |
(obsolete)
T
|
qScriptValueToValue (const QScriptValue & value ) |
此函數已過時。提供它是為使舊源代碼能繼續工作。強烈建議不要在新代碼中使用它。
返迴 true 若 program can be evaluated; i.e. the code is sufficient to determine whether it appears to be a syntactically correct program, or contains a syntax error.
This function returns false if program is incomplete; i.e. the input is syntactically correct up to the point where the input is terminated.
Note that this function only does a static check of program ; e.g. it does not check whether references to variables are valid, and so on.
A typical usage of canEvaluate() is to implement an interactive interpreter for Qt Script. The user is repeatedly queried for individual lines of code; the lines are concatened internally, and only when canEvaluate() returns true for the resulting program is it passed to evaluate ().
The following are some examples to illustrate the behavior of canEvaluate(). (Note that all example inputs are assumed to have an explicit newline as their last character, since otherwise the Qt Script parser would automatically insert a semi-colon character at the end of the input, and this could cause canEvaluate() to produce different results.)
Given the input
if (hello && world) print("hello world");
canEvaluate() will return true, since the program appears to be complete.
Given the input
if (hello &&
canEvaluate() will return false, since the if-statement is not complete, but is syntactically correct so far.
Given the input
0 = 0
canEvaluate() will return true, but evaluate () will throw a SyntaxError given the same input.
Given the input
./test.js
canEvaluate() will return true, even though the code is clearly not syntactically valid Qt Script code. evaluate () will throw a SyntaxError when this code is evaluated.
Given the input
foo["bar"]
canEvaluate() will return true, but
evaluate
() will throw a ReferenceError if
foo
is not defined in the script environment.
另請參閱 evaluate () 和 checkSyntax ().
此函數已過時。提供它是為使舊源代碼能繼續工作。強烈建議不要在新代碼中使用它。
創建
QScriptValue
使用給定
engine
采用給定
value
of template type
T
.
此函數相當於 QScriptEngine::toScriptValue ().
注意: 此函數是為不支持成員模闆函數的 MSVC 6 提供的解決方案。建議在新代碼中使用其它形式。
該函數在 Qt 4.3 引入。
另請參閱 QScriptEngine::toScriptValue () 和 qscriptvalue_cast ().
此函數已過時。提供它是為使舊源代碼能繼續工作。強烈建議不要在新代碼中使用它。
返迴給定
value
被轉換成模闆類型
T
.
此函數相當於 QScriptEngine::fromScriptValue ().
注意: 此函數是為不支持成員模闆函數的 MSVC 6 提供的解決方案。建議在新代碼中使用其它形式。
該函數在 Qt 4.3 引入。
另請參閱 QScriptEngine::fromScriptValue ().