Qt 4.8
|
The QAxScript class provides a wrapper around script code. More...
#include <qaxscript.h>
Public Types | |
enum | FunctionFlags { FunctionNames = 0, FunctionSignatures } |
This FunctionFlags enum describes formatting for function introspection. More... | |
Signals | |
void | entered () |
This signal is emitted when a script engine has started executing code. More... | |
void | error (int code, const QString &description, int sourcePosition, const QString &sourceText) |
This signal is emitted when an execution error occurred while running a script. More... | |
void | finished () |
This signal is emitted when a script engine has finished executing code. More... | |
void | finished (const QVariant &result) |
QVariant if the script has no return value. More... | |
void | finished (int code, const QString &source, const QString &description, const QString &help) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.code, source, description and help contain exception information when the script terminated. More... | |
void | stateChanged (int state) |
This signal is emitted when a script engine changes state. More... | |
Signals inherited from QObject | |
void | destroyed (QObject *=0) |
This signal is emitted immediately before the object obj is destroyed, and can not be blocked. More... | |
Public Functions | |
QVariant | call (const QString &function, const QVariant &v1=QVariant(), const QVariant &v2=QVariant(), const QVariant &v3=QVariant(), const QVariant &v4=QVariant(), const QVariant &v5=QVariant(), const QVariant &v6=QVariant(), const QVariant &v7=QVariant(), const QVariant &v8=QVariant()) |
Calls function, passing the parameters var1, var1, var2, var3, var4, var5, var6, var7 and var8 as arguments and returns the value returned by the function, or an invalid QVariant if the function does not return a value or when the function call failed. More... | |
QVariant | call (const QString &function, QList< QVariant > &arguments) |
Calls function passing arguments as parameters, and returns the result. More... | |
QStringList | functions (FunctionFlags=FunctionNames) const |
Returns a list of all the functions in this script if the respective script engine supports introspection; otherwise returns an empty list. More... | |
bool | load (const QString &code, const QString &language=QString()) |
Loads the script source code written in language language into the script engine. More... | |
QAxScript (const QString &name, QAxScriptManager *manager) | |
Constructs a QAxScript object called name and registers it with the QAxScriptManager manager. More... | |
QString | scriptCode () const |
Returns the script's code, or the null-string if no code has been loaded yet. More... | |
QAxScriptEngine * | scriptEngine () const |
Returns a pointer to the script engine. More... | |
QString | scriptName () const |
Returns the name of the script. More... | |
~QAxScript () | |
Destroys the object, releasing all allocated resources. More... | |
Public Functions inherited from QObject | |
bool | blockSignals (bool b) |
If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke anything connected to it). More... | |
const QObjectList & | children () const |
Returns a list of child objects. More... | |
bool | connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const |
bool | disconnect (const char *signal=0, const QObject *receiver=0, const char *member=0) |
bool | disconnect (const QObject *receiver, const char *member=0) |
void | dumpObjectInfo () |
Dumps information about signal connections, etc. More... | |
void | dumpObjectTree () |
Dumps a tree of children to the debug output. More... | |
QList< QByteArray > | dynamicPropertyNames () const |
Returns the names of all properties that were dynamically added to the object using setProperty(). More... | |
virtual bool | event (QEvent *) |
This virtual function receives events to an object and should return true if the event e was recognized and processed. More... | |
virtual bool | eventFilter (QObject *, QEvent *) |
Filters events if this object has been installed as an event filter for the watched object. More... | |
template<typename T > | |
T | findChild (const QString &aName=QString()) const |
Returns the child of this object that can be cast into type T and that is called name, or 0 if there is no such object. More... | |
template<typename T > | |
QList< T > | findChildren (const QString &aName=QString()) const |
Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects. More... | |
template<typename T > | |
QList< T > | findChildren (const QRegExp &re) const |
bool | inherits (const char *classname) const |
Returns true if this object is an instance of a class that inherits className or a QObject subclass that inherits className; otherwise returns false. More... | |
void | installEventFilter (QObject *) |
Installs an event filter filterObj on this object. More... | |
bool | isWidgetType () const |
Returns true if the object is a widget; otherwise returns false. More... | |
void | killTimer (int id) |
Kills the timer with timer identifier, id. More... | |
virtual const QMetaObject * | metaObject () const |
Returns a pointer to the meta-object of this object. More... | |
void | moveToThread (QThread *thread) |
Changes the thread affinity for this object and its children. More... | |
QString | objectName () const |
QObject * | parent () const |
Returns a pointer to the parent object. More... | |
QVariant | property (const char *name) const |
Returns the value of the object's name property. More... | |
Q_INVOKABLE | QObject (QObject *parent=0) |
Constructs an object with parent object parent. More... | |
void | removeEventFilter (QObject *) |
Removes an event filter object obj from this object. More... | |
void | setObjectName (const QString &name) |
void | setParent (QObject *) |
Makes the object a child of parent. More... | |
bool | setProperty (const char *name, const QVariant &value) |
Sets the value of the object's name property to value. More... | |
void | setUserData (uint id, QObjectUserData *data) |
bool | signalsBlocked () const |
Returns true if signals are blocked; otherwise returns false. More... | |
int | startTimer (int interval) |
Starts a timer and returns a timer identifier, or returns zero if it could not start a timer. More... | |
QThread * | thread () const |
Returns the thread in which the object lives. More... | |
QObjectUserData * | userData (uint id) const |
virtual | ~QObject () |
Destroys the object, deleting all its child objects. More... | |
Private Functions | |
QAxBase * | findObject (const QString &name) |
Returns the object name registered with the manager. More... | |
void | updateObjects () |
Registers all objects in the manager with the script engine. More... | |
Properties | |
QString | script_code |
QAxScriptEngine * | script_engine |
QAxScriptManager * | script_manager |
QString | script_name |
QAxScriptSite * | script_site |
Friends | |
class | QAxScriptEngine |
class | QAxScriptSite |
Additional Inherited Members | |
Public Slots inherited from QObject | |
void | deleteLater () |
Schedules this object for deletion. More... | |
Static Public Functions inherited from QObject | |
static bool | connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection) |
Creates a connection of the given type from the signal in the sender object to the method in the receiver object. More... | |
static bool | connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type=Qt::AutoConnection) |
static bool | disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member) |
Disconnects signal in object sender from method in object receiver. More... | |
static bool | disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &member) |
static uint | registerUserData () |
static QString | tr (const char *sourceText, const char *comment=0, int n=-1) |
static QString | trUtf8 (const char *sourceText, const char *comment=0, int n=-1) |
Static Public Variables inherited from QObject | |
static const QMetaObject | staticMetaObject |
This variable stores the meta-object for the class. More... | |
Protected Functions inherited from QObject | |
virtual void | childEvent (QChildEvent *) |
This event handler can be reimplemented in a subclass to receive child events. More... | |
virtual void | connectNotify (const char *signal) |
This virtual function is called when something has been connected to signal in this object. More... | |
virtual void | customEvent (QEvent *) |
This event handler can be reimplemented in a subclass to receive custom events. More... | |
virtual void | disconnectNotify (const char *signal) |
This virtual function is called when something has been disconnected from signal in this object. More... | |
QObject (QObjectPrivate &dd, QObject *parent=0) | |
int | receivers (const char *signal) const |
Returns the number of receivers connected to the signal. More... | |
QObject * | sender () const |
Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; otherwise it returns 0. More... | |
int | senderSignalIndex () const |
virtual void | timerEvent (QTimerEvent *) |
This event handler can be reimplemented in a subclass to receive timer events for the object. More... | |
Protected Variables inherited from QObject | |
QScopedPointer< QObjectData > | d_ptr |
Static Protected Variables inherited from QObject | |
static const QMetaObject | staticQtMetaObject |
Related Functions inherited from QObject | |
T | qFindChildqFindChildren (const QObject *obj, const QString &name)() |
QList< T > | qFindChildrenqFindChildren (const QObject *obj, const QString &name)() |
QList< T > | qFindChildrenqFindChildren (const QObject *obj, const QRegExp ®Exp)() |
T * | qobject_cast (QObject *object) |
QObjectList | |
void * | qt_find_obj_child (QObject *parent, const char *type, const QString &name) |
Returns a pointer to the object named name that inherits type and with a given parent. More... | |
The QAxScript class provides a wrapper around script code.
Every instance of the QAxScript class represents a piece of scripting code in a particular scripting language. The code is loaded into the script engine using load(). Functions declared in the code can be called using call().
The script provides scriptEngine() provides feedback to the application through signals. The most important signal is the error() signal. Direct access to the QAxScriptEngine is provided through the scriptEngine() function.
Definition at line 100 of file qaxscript.h.
This FunctionFlags enum describes formatting for function introspection.
Enumerator | |
---|---|
FunctionNames | |
FunctionSignatures |
Definition at line 105 of file qaxscript.h.
QAxScript::QAxScript | ( | const QString & | name, |
QAxScriptManager * | manager | ||
) |
Constructs a QAxScript object called name and registers it with the QAxScriptManager manager.
This is usually done by the QAxScriptManager class when loading a script.
A script should always have a name. A manager is necessary to allow the script code to reference objects in the application. The manager takes ownership of the object.
Definition at line 676 of file qaxscript.cpp.
QAxScript::~QAxScript | ( | ) |
Destroys the object, releasing all allocated resources.
Definition at line 696 of file qaxscript.cpp.
QVariant QAxScript::call | ( | const QString & | function, |
const QVariant & | var1 = QVariant() , |
||
const QVariant & | var2 = QVariant() , |
||
const QVariant & | var3 = QVariant() , |
||
const QVariant & | var4 = QVariant() , |
||
const QVariant & | var5 = QVariant() , |
||
const QVariant & | var6 = QVariant() , |
||
const QVariant & | var7 = QVariant() , |
||
const QVariant & | var8 = QVariant() |
||
) |
Calls function, passing the parameters var1, var1, var2, var3, var4, var5, var6, var7 and var8 as arguments and returns the value returned by the function, or an invalid QVariant if the function does not return a value or when the function call failed.
See QAxScriptManager::call() for more information about how to call script functions.
Definition at line 793 of file qaxscript.cpp.
Referenced by QAxScriptManager::call().
Calls function passing arguments as parameters, and returns the result.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Returns when the script's execution has finished.
See QAxScriptManager::call() for more information about how to call script functions.
Definition at line 820 of file qaxscript.cpp.
|
signal |
This signal is emitted when a script engine has started executing code.
Referenced by QAxScriptSite::OnEnterScript().
|
signal |
This signal is emitted when an execution error occurred while running a script.
code, description, sourcePosition and sourceText contain information about the execution error.
Referenced by QAxScriptSite::OnScriptError(), and QAxScript().
Returns the object name registered with the manager.
Definition at line 848 of file qaxscript.cpp.
Referenced by QAxScriptSite::GetItemInfo().
|
signal |
This signal is emitted when a script engine has finished executing code.
Referenced by QAxScriptSite::OnLeaveScript(), and QAxScriptSite::OnScriptTerminate().
|
signal |
QVariant if the script has no return value.
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
result contains the script's result. This will be an invalid
|
signal |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.code, source, description and help contain exception information when the script terminated.
QStringList QAxScript::functions | ( | FunctionFlags | flags = FunctionNames | ) | const |
Returns a list of all the functions in this script if the respective script engine supports introspection; otherwise returns an empty list.
The functions are either provided with full prototypes or only as names, depending on the value of flags.
Definition at line 761 of file qaxscript.cpp.
Referenced by QAxScriptManager::functions(), and QAxScriptManager::scriptForFunction().
Loads the script source code written in language language into the script engine.
Returns true if code was successfully entered into the script engine; otherwise returns false.
If language is empty (the default) it will be determined heuristically. If code contains the string {End
Sub} it will be interpreted as VBScript, otherwise as JScript. Additional scripting languages can be registered using QAxScript::registerEngine().
This function can only be called once for each QAxScript object, which is done automatically when using QAxScriptManager::load().
Definition at line 720 of file qaxscript.cpp.
Referenced by QAxScriptManager::load().
|
inline |
Returns the script's code, or the null-string if no code has been loaded yet.
Definition at line 202 of file qaxscript.h.
Referenced by QAxScriptEngine::initialize().
|
inline |
Returns a pointer to the script engine.
You can use the object returned to connect signals to the script functions, or to access the script engine directly.
Definition at line 212 of file qaxscript.h.
Referenced by QAxScriptManager::updateScript().
|
inline |
|
signal |
This signal is emitted when a script engine changes state.
state can be any value in the QAxScriptEngineState enumeration.
Referenced by QAxScriptSite::OnStateChange().
|
private |
Registers all objects in the manager with the script engine.
Definition at line 834 of file qaxscript.cpp.
Referenced by QAxScriptEngine::initialize().
|
friend |
Definition at line 141 of file qaxscript.h.
Referenced by load().
|
friend |
Definition at line 140 of file qaxscript.h.
Referenced by QAxScript().
|
private |
Definition at line 147 of file qaxscript.h.
Referenced by load().
|
private |
Definition at line 149 of file qaxscript.h.
Referenced by call(), functions(), load(), scriptEngine(), and ~QAxScript().
|
private |
Definition at line 148 of file qaxscript.h.
Referenced by findObject(), and updateObjects().
|
private |
Definition at line 146 of file qaxscript.h.
Referenced by scriptName().
|
private |
Definition at line 150 of file qaxscript.h.
Referenced by QAxScriptEngine::initialize(), QAxScript(), and ~QAxScript().