以下成员源于类 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 ().