Movatterモバイル変換


[0]ホーム

URL:


We bake cookies in your browser for a better experience. Using this site means that you consent.Read More

Menu

Qt Documentation

QScriptContextInfo Class

TheQScriptContextInfo class provides additional information about aQScriptContext.More...

Header:#include <QScriptContextInfo>
Since: Qt 4.4

Public Types

enumFunctionType { ScriptFunction, QtFunction, QtPropertyFunction, NativeFunction }

Public Functions

QScriptContextInfo(const QScriptContext * context)
QScriptContextInfo(const QScriptContextInfo & other)
QScriptContextInfo()
~QScriptContextInfo()
QStringfileName() const
intfunctionEndLineNumber() const
intfunctionMetaIndex() const
QStringfunctionName() const
QStringListfunctionParameterNames() const
intfunctionStartLineNumber() const
FunctionTypefunctionType() const
boolisNull() const
intlineNumber() const
qint64scriptId() const
booloperator!=(const QScriptContextInfo & other) const
QScriptContextInfo &operator=(const QScriptContextInfo & other)
booloperator==(const QScriptContextInfo & other) const

Related Non-Members

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

Detailed Description

TheQScriptContextInfo class provides additional information about aQScriptContext.

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 functionsfileName() andlineNumber().

You can obtain the starting line number and ending line number of a Qt Script function definition withfunctionStartLineNumber() andfunctionEndLineNumber(), respectively.

For Qt Script functions and Qt methods (e.g. slots), you can callfunctionParameterNames() 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 underlyingQMetaMethod orQMetaProperty by callingfunctionMetaIndex().

See alsoQScriptContext andQScriptEngineAgent.

Member Type Documentation

enum QScriptContextInfo::FunctionType

This enum specifies the type of function being called.

ConstantValueDescription
QScriptContextInfo::ScriptFunction0The function is a Qt Script function, i.e. it was defined through a call toQScriptEngine::evaluate().
QScriptContextInfo::QtFunction1The function is a Qt function (a signal, slot or method).
QScriptContextInfo::QtPropertyFunction2The function is a Qt property getter or setter.
QScriptContextInfo::NativeFunction3The function is a built-in Qt Script function, or it was defined through a call toQScriptEngine::newFunction().

Member Function Documentation

QScriptContextInfo::QScriptContextInfo(constQScriptContext * context)

Constructs a newQScriptContextInfo from the givencontext.

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

QScriptContextInfo::QScriptContextInfo(constQScriptContextInfo & other)

Constructs a newQScriptContextInfo from theother info.

QScriptContextInfo::QScriptContextInfo()

Constructs a nullQScriptContextInfo.

See alsoisNull().

QScriptContextInfo::~QScriptContextInfo()

Destroys theQScriptContextInfo.

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 toQScriptEngine::evaluate().

See alsolineNumber() andfunctionName().

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 thefunctionType() isScriptFunction.

See alsofunctionStartLineNumber().

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 thefunctionType() isQtFunction orQtPropertyFunction. ForQtFunction, the meta index can be passed toQMetaObject::method() to obtain the corresponding method definition; forQtPropertyFunction, the meta index can be passed toQMetaObject::property() to obtain the corresponding property definition.

See alsoQScriptContext::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 typeQtPropertyFunction, this function always returns the name of the property; you can useQScriptContext::argumentCount() to differentiate between reads and writes.

See alsofileName() andfunctionType().

QStringList QScriptContextInfo::functionParameterNames() const

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

See alsoQScriptContext::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 thefunctionType() isScriptFunction.

See alsofunctionEndLineNumber() andfileName().

FunctionType QScriptContextInfo::functionType() const

Returns the type of the called function.

See alsofunctionName() andQScriptContext::callee().

bool QScriptContextInfo::isNull() const

Returns true if thisQScriptContextInfo 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.

See alsocolumnNumber() andfileName().

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).

See alsoQScriptEngineAgent::scriptLoad().

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

Returns true if thisQScriptContextInfo is not equal to theother info, otherwise returns false.

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

Assigns theother info to thisQScriptContextInfo, and returns a reference to thisQScriptContextInfo.

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

Returns true if thisQScriptContextInfo is equal to theother info, otherwise returns false.

Related Non-Members

QDataStream &operator<<(QDataStream & stream, constQScriptContextInfo & info)

Writes the giveninfo to the specifiedstream.

This function was introduced in Qt 4.4.

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

Reads aQScriptContextInfo from the specifiedstream into the giveninfo.

This function was introduced in Qt 4.4.

© 2016 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of theGNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.


[8]ページ先頭

©2009-2025 Movatter.jp