QScriptContextInfo Class

The QScriptContextInfo class provides additional information about a QScriptContext . 更多...

头: #include <QScriptContextInfo>
qmake: QT += script
Since: Qt 4.4

公共类型

enum FunctionType { ScriptFunction, QtFunction, QtPropertyFunction, NativeFunction }

公共函数

QScriptContextInfo (const QScriptContext * context )
QScriptContextInfo (const QScriptContextInfo & other )
QScriptContextInfo ()
~QScriptContextInfo ()
QString fileName () const
int functionEndLineNumber () const
int functionMetaIndex () const
QString functionName () const
QStringList functionParameterNames () const
int functionStartLineNumber () const
FunctionType functionType () const
bool isNull () const
int lineNumber () const
qint64 scriptId () const
bool operator!= (const QScriptContextInfo & other ) const
QScriptContextInfo & operator= (const QScriptContextInfo & other )
bool operator== (const QScriptContextInfo & other ) const
QDataStream & operator<< (QDataStream & stream , const QScriptContextInfo & info )
QDataStream & operator>> (QDataStream & stream , QScriptContextInfo & info )

详细描述

The QScriptContextInfo class provides additional information about a QScriptContext .

QScriptContextInfo is typically used for debugging purposes. It can provide information about the code being executed, such as the type of the called function, and the original source code location of the current statement.

If the called function is executing Qt Script code, you can obtain the script location with the functions fileName () 和 lineNumber ().

You can obtain the starting line number and ending line number of a Qt Script function definition with functionStartLineNumber () 和 functionEndLineNumber () 分别。

For Qt Script functions and Qt methods (e.g. slots), you can call functionParameterNames () to get the names of the formal parameters of the function.

For Qt methods and Qt property accessors, you can obtain the index of the underlying QMetaMethod or QMetaProperty 通过调用 functionMetaIndex ().

另请参阅 QScriptContext and QScriptEngineAgent .

成员类型文档编制

enum QScriptContextInfo:: FunctionType

This enum specifies the type of function being called.

常量 描述
QScriptContextInfo::ScriptFunction 0 The function is a Qt Script function, i.e. it was defined through a call to QScriptEngine::evaluate ().
QScriptContextInfo::QtFunction 1 The function is a Qt function (a signal, slot or method).
QScriptContextInfo::QtPropertyFunction 2 The function is a Qt property getter or setter.
QScriptContextInfo::NativeFunction 3 The function is a built-in Qt Script function, or it was defined through a call to QScriptEngine::newFunction ().

成员函数文档编制

QScriptContextInfo:: QScriptContextInfo (const QScriptContext * context )

构造新的 QScriptContextInfo 从给定 context .

The relevant information is extracted from the context at construction time; i.e. if you continue script execution in the context , the new state of the context will not be reflected in a previously created QScriptContextInfo .

QScriptContextInfo:: QScriptContextInfo (const QScriptContextInfo & other )

构造新的 QScriptContextInfo other info.

QScriptContextInfo:: QScriptContextInfo ()

Constructs a null QScriptContextInfo .

另请参阅 isNull ().

QScriptContextInfo:: ~QScriptContextInfo ()

销毁 QScriptContextInfo .

QString QScriptContextInfo:: fileName () const

Returns the name of the file where the code being executed was defined, if available; otherwise returns an empty string.

For Qt Script code, this function returns the fileName argument that was passed to QScriptEngine::evaluate ().

另请参阅 lineNumber () 和 functionName ().

int QScriptContextInfo:: functionEndLineNumber () const

Returns the line number where the definition of the called function ends, or -1 if the line number is not available.

The ending line number is only available if the functionType () 是 ScriptFunction .

另请参阅 functionStartLineNumber ().

int QScriptContextInfo:: functionMetaIndex () const

Returns the meta index of the called function, or -1 if the meta index is not available.

The meta index is only available if the functionType () 是 QtFunction or QtPropertyFunction 。对于 QtFunction , the meta index can be passed to QMetaObject::method () to obtain the corresponding method definition; for QtPropertyFunction , the meta index can be passed to QMetaObject::property () to obtain the corresponding property definition.

另请参阅 QScriptContext::thisObject ().

QString QScriptContextInfo:: functionName () const

Returns the name of the called function, or an empty string if the name is not available.

For script functions of type QtPropertyFunction , this function always returns the name of the property; you can use QScriptContext::argumentCount () to differentiate between reads and writes.

另请参阅 fileName () 和 functionType ().

QStringList QScriptContextInfo:: functionParameterNames () const

Returns the names of the formal parameters of the called function, or an empty QStringList if the parameter names are not available.

另请参阅 QScriptContext::argument ().

int QScriptContextInfo:: functionStartLineNumber () const

Returns the line number where the definition of the called function starts, or -1 if the line number is not available.

The starting line number is only available if the functionType () 是 ScriptFunction .

另请参阅 functionEndLineNumber () 和 fileName ().

FunctionType QScriptContextInfo:: functionType () const

Returns the type of the called function.

另请参阅 functionName () 和 QScriptContext::callee ().

bool QScriptContextInfo:: isNull () const

返回 true,若此 QScriptContextInfo is null, i.e. does not contain any information.

int QScriptContextInfo:: lineNumber () const

Returns the line number corresponding to the statement being executed, or -1 if the line number is not available.

The line number is only available if Qt Script code is being executed.

另请参阅 columnNumber () 和 fileName ().

qint64 QScriptContextInfo:: scriptId () const

Returns the ID of the script where the code being executed was defined, or -1 if the ID is not available (i.e. a native function is being executed).

另请参阅 QScriptEngineAgent::scriptLoad ().

bool QScriptContextInfo:: operator!= (const QScriptContextInfo & other ) const

返回 true,若此 QScriptContextInfo is not equal to the other info, otherwise returns false.

QScriptContextInfo &QScriptContextInfo:: operator= (const QScriptContextInfo & other )

赋值 other info to this QScriptContextInfo , and returns a reference to this QScriptContextInfo .

bool QScriptContextInfo:: operator== (const QScriptContextInfo & other ) const

返回 true,若此 QScriptContextInfo is equal to the other info, otherwise returns false.

相关非成员

QDataStream & operator<< ( QDataStream & stream , const QScriptContextInfo & info )

写入给定 info 到指定 stream .

该函数在 Qt 4.4 引入。

QDataStream & operator>> ( QDataStream & stream , QScriptContextInfo & info )

读取 QScriptContextInfo 从指定 stream 进给定 info .

该函数在 Qt 4.4 引入。