| Tutorial | Classes | Functions | QSA Developer | Language | Library | Qt API | Qt Script for Applications | ![]() |
The QSProject class provides control over a script project for the Qt Application Script interpreter. More...
#include <qsproject.h>
The QSProject class provides control over a script project for the Qt Application Script interpreter.
Qt Script for Applications (QSA) collects sets of functions and classes together in projects. Use open() to access a project, either from a file or from a byte array. If a file is used, QSA will automatically take care of saving user changes. The project's data can be retrieved into a byte array using projectData(). One project is current at any one time; close the current project with clear().
The contents of the current project are available using forms() and classes() which return a list of all the forms and classes respectively.
A new global function can be added with addFunction(); this function can also invoke QSA Developer if required. QSA Developer is invoked with openDeveloper() and closed with closeDeveloper().
If QSA Developer is too complex for your application (even with the GUI builder functionality and/or the debugger switched off), you can use QSEditor to create a source code editor for Qt Script (with syntax highlighting, completion, auto indentation, etc), which can be embedded into your application user interface.
See the Manual for more explanation and examples.
The DeveloperFlags describe in which mode QSA Developer is opened.
See also removeForm().
The code for the function can be passed in the functionBody parameter. If openDeveloper is TRUE (the default), then QSA Developer will be invoked so that the user can edit this function. If functionBody was specified its text will appear in the editor; if the functionBody is empty a new empty function will be created. If the function functionName already exists in the project and openDeveloper is TRUE, QSA Developer will be invoked showing the already existing function in the editor (and any functionBody will be discarded).
This function returns TRUE on success (i.e. the functionName was valid); otherwise returns FALSE.
If there is no project currently open this function does nothing.
If there has been added code already under the name fileName, code is appended to this code if append is TRUE, otherwise the currently set code is replaced with code.
See also removeSource().
If there is no project currently open this function does nothing.
This function clears the interpreter, so code which has been passed into previous evaluate() calls will be lost.
See also forms() and formXML().
See also forms() and formSource().
See also formSource() and formXML().
After open() is called, functions, classes and forms defined in this project can be called and used using evaluate() and call().
If the project has signal/slot connections (for example, a form that connects widget signals to Qt Script slots), then these connections are established as part of the open() process.
The project always stops when QSA Developer is opened, and continues when QSA Developer is closed.
Reads and parses the Qt Script for Applications script from the projectData QByteArray. projectName must be specified.
If an error occurs while running or parsing the script, the error() signal is emitted, and further action may occur depending on the errorMode().
After open() is called, functions, classes and forms defined in this project can be called and used inside call() and evaluate() calls.
If the project has signal/slot connections (for example, a form that connects widget signals to Qt Script slots), then these connections are established as part of the open() process.
The project always stops when the QSA Developer is invoked, and continues when the QSA Developer is closed.
flags is a value which can contains values of DeveloperFlags or'd together.
If there is no project currently open this function does nothing.
This function clears the interpreter, so code which has been passed into previous evaluate() calls will be lost.
If you created QSEditors, the QSA Developer is always opened with read only editors, even if EditableEditor is part of flags, so that the QSA Developer can be used for debugging, but not editing.
This is useful for keeping the project data with a document. For example, you could take the data returned by this function and store it in a document's file. Later, when the document was opened, you could extract this data from the document and pass it to the overload of open() that takes a QByteArray to reconstruct the project.
See also addForm().
See also addSource().
This file is part of Qt Script for Applications, copyright © 2001-2002 Trolltech. All Rights Reserved.
Copyright © 2001-2002 Trolltech | Trademarks | QSA version 1.0.0-beta1
|