Home · Tutorial · Classes · Functions · Language · QSA Workbench · Qt Documentation · www.trolltech.com

QSScript Class Reference

The QSScript class provides encapsulation of a script written in Qt Script. More...

    #include <QSScript>

Public Functions


Detailed Description

The QSScript class provides encapsulation of a script written in Qt Script.

A script is a container for a script written in Qt Script. It always belongs to a project and it can only be created using the QSProject::createScript() functions. The QSScript can be associated with a QObject which will serve as the context ( this ) when the script is evaluated. QSScripts and their contexts, if any, are associated by name as follows:

    script->name() == script->context()->name()

Use the functions setCode(), addCode(), and addFunction() to modify the contents of the script. Use the function code() to retreive the contents in the script. When the script is changed, the signal codeChanged() is emitted.

Member Function Documentation

void QSScript::addCode ( const QString & code )

Appends the code code to the code in this script. This function will emit codeChanged()

bool QSScript::addFunction ( const QString & functionName, const QString & functionBody = QString::null )

A function called functionName is added to this script. The name must match the regular expression /^[A-Za-z_][A-Za-z_0-9]*$/.

The code for the function can be passed in the functionBody parameter. If functionBody was specified, its text will appear in the editor; if the functionBody is empty a new empty function will be created.

This function returns true on success (i.e. the functionName was valid); otherwise returns false.

QString QSScript::code () const

Returns the scriptcode.

See also setCode().

void QSScript::codeChanged ()   [signal]

This signal is emitted whenever the scriptcode has changed.

QObject * QSScript::context () const

Returns the context of the script if the script has context; otherwise returns 0.

The name of the context context()->name() is to be the same name as this script.

QString QSScript::name () const

Returns the name of the script. If the script has a context, this name is the same as the object name of the context (context()->objectName().)

QSProject * QSScript::project () const

Returns the project that this script belongs to.

void QSScript::setCode ( const QString & code )

Sets the code in this script to code. This function will emit codeChanged().

See also code().

Copyright © 2006 Trolltech Trademarks
QSA 1.2.2