QScriptProgram Class

The QScriptProgram class encapsulates a Qt Script program. More...

Header: #include <QScriptProgram>
qmake: QT += script
Since: Qt 4.7

Public Functions

QScriptProgram()
QScriptProgram(const QString &sourceCode, const QString fileName = QString(), int firstLineNumber = 1)
QScriptProgram(const QScriptProgram &other)
~QScriptProgram()
QString fileName() const
int firstLineNumber() const
bool isNull() const
QString sourceCode() const
bool operator!=(const QScriptProgram &other) const
QScriptProgram & operator=(const QScriptProgram &other)
bool operator==(const QScriptProgram &other) const

Detailed Description

The QScriptProgram class encapsulates a Qt Script program.

QScriptProgram retains the compiled representation of the script if possible. Thus, QScriptProgram can be used to evaluate the same script multiple times more efficiently.

QScriptEngine engine;
QScriptProgram program("1 + 2");
QScriptValue result = engine.evaluate(program);

Member Function Documentation

QScriptProgram::QScriptProgram()

Constructs a null QScriptProgram.

QScriptProgram::QScriptProgram(const QString &sourceCode, const QString fileName = QString(), int firstLineNumber = 1)

Constructs a new QScriptProgram with the given sourceCode, fileName and firstLineNumber.

QScriptProgram::QScriptProgram(const QScriptProgram &other)

Constructs a new QScriptProgram that is a copy of other.

QScriptProgram::~QScriptProgram()

Destroys this QScriptProgram.

QString QScriptProgram::fileName() const

Returns the filename associated with this program.

int QScriptProgram::firstLineNumber() const

Returns the line number associated with this program.

bool QScriptProgram::isNull() const

Returns true if this QScriptProgram is null; otherwise returns false.

QString QScriptProgram::sourceCode() const

Returns the source code of this program.

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

Returns true if this QScriptProgram is not equal to other; otherwise returns false.

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

Assigns the other value to this QScriptProgram.

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

Returns true if this QScriptProgram is equal to other; otherwise returns false.

Voted #1 for:

  • Easiest to learn
  • Most time saving
  • Best support

Develop Cross-Platform Apps and Games 50% Faster!

  • Voted the best supported, most time-saving and easiest to learn cross-platform development tool
  • Based on the Qt framework, with native performance and appearance on all platforms including iOS and Android
  • Offers a variety of plugins to monetize, analyze and engage users
FREE!
create apps
create games
cross platform
native performance
3rd party services
game network
multiplayer
level editor
easiest to learn
biggest time saving
best support