1QAxScriptManager(3qt) QAxScriptManager(3qt)
2
3
4
6 QAxScriptManager - Bridge between application objects and script code
7
9 This class is part of the Qt ActiveQt Extension.
10
11 #include <qaxscript.h>
12
13 Inherits QObject.
14
15 Public Members
16 QAxScriptManager ( QObject * parent = 0, const char * name = 0 )
17 ~QAxScriptManager ()
18 void addObject ( QAxBase * object )
19 void addObject ( QObject * object )
20 QStringList functions ( QAxScript::FunctionFlags flags =
21 QAxScript::FunctionNames ) const
22 QStringList scriptNames () const
23 QAxScript * script ( const QString & name ) const
24 QAxScript * load ( const QString & code, const QString & name, const
25 QString & language )
26 QAxScript * load ( const QString & file, const QString & name )
27 QVariant call ( const QString & function, const QVariant & var1 =
28 QVariant ( ), const QVariant & var2 = QVariant ( ), const QVariant
29 & var3 = QVariant ( ), const QVariant & var4 = QVariant ( ), const
30 QVariant & var5 = QVariant ( ), const QVariant & var6 = QVariant (
31 ), const QVariant & var7 = QVariant ( ), const QVariant & var8 =
32 QVariant ( ) )
33 QVariant call ( const QString & function, QValueList<QVariant> &
34 arguments )
35
36 Signals
37 void error ( QAxScript * script, int code, const QString & description,
38 int sourcePosition, const QString & sourceText )
39
40 Static Public Members
41 bool registerEngine ( const QString & name, const QString & extension,
42 const QString & code = QString ( ) )
43 QString scriptFileFilter ()
44
46 This class is defined in the Qt ActiveQt Extension, which can be found
47 in the qt/extensions directory. It is not included in the main Qt API.
48
49 The QAxScriptManager class provides a bridge between application
50 objects and script code.
51
52 The QAxScriptManager acts as a bridge between the COM objects embedded
53 in the Qt application through QAxObject or QAxWidget, and the scripting
54 languages available through the Windows Script technologies, usually
55 JScript and VBScript.
56
57 Create one QAxScriptManager for each separate document in your
58 application, and add the COM objects the scripts need to access using
59 addObject(). Then load() the script sources and invoke the functions
60 using call().
61
62 Warning: This class is not available with the bcc5.5 and MingW
63 compilers.
64
67 0 )
68 Creates a QAxScriptManager object. parent and name are passed on to the
69 QObject constructor.
70
71 It is usual to create one QAxScriptManager for each document in an
72 application.
73
75 Destroys the objects, releasing all allocated resources.
76
78 Adds object to the manager. Scripts handled by this manager can access
79 the object in the code using the object's name property.
80
81 You must add all the necessary objects before loading any scripts.
82
84 This is an overloaded member function, provided for convenience. It
85 behaves essentially like the above function.
86
87 Adds a generic COM wrapper for object to the manager. object must be
88 exposed as a COM object using the functionality provided by the
89 QAxServer module.. Applications using this function you must link
90 against the qaxserver library.
91
93 var1 = QVariant ( ), const QVariant & var2 = QVariant ( ), const
94 QVariant & var3 = QVariant ( ), const QVariant & var4 = QVariant ( ),
95 const QVariant & var5 = QVariant ( ), const QVariant & var6 = QVariant
96 ( ), const QVariant & var7 = QVariant ( ), const QVariant & var8 =
97 QVariant ( ) )
98 Calls function, passing the parameters var1, var1, var2, var3, var4,
99 var5, var6, var7 and var8 as arguments and returns the value returned
100 by the function, or an invalid QVariant if the function does not return
101 a value or when the function call failed. The call returns when the
102 script's execution has finished.
103
104 In most script engines the only supported parameter type is "const
105 QVariant&", for example, to call a JavaScript function
106
107 function setNumber(number)
108 {
109 n = number;
110 }
111 use
112
113 QValueList args;
114 args << 5;
115 script->call("setNumber(const QVariant&)", args);
116 As with dynamicCall the parameters can directly be embedded in the
117 function string.
118
119 script->call("setNumber(5)");
120 However, this is slower.
121
122 Functions provided by script engines that don't support introspection
123 are not available and must be called directly using QAxScript::call()
124 on the respective script object.
125
126 Note that calling this function can be significantely slower than using
127 call() on the respective QAxScript directly.
128
130 QValueList<QVariant> & arguments )
131 This is an overloaded member function, provided for convenience. It
132 behaves essentially like the above function.
133
134 Calls function passing arguments as parameters, and returns the result.
135 Returns when the script's execution has finished.
136
138 description, int sourcePosition, const QString & sourceText ) [signal]
139 This signal is emitted when an execution error occured while running
140 script.
141
142 code, description, sourcePosition and sourceText contain information
143 about the execution error.
144
146 QAxScript::FunctionNames ) const
147 Returns a list with all the functions that are available. Functions
148 provided by script engines that don't support introspection are not
149 included in the list. The functions are either provided with full
150 prototypes or only as names, depending on the value of flags.
151
153 name, const QString & language )
154 Loads the script source code using the script engine for language. The
155 script can later be referred to using its name which should not be
156 empty.
157
158 The function returns a pointer to the script for the given code if the
159 code was loaded successfully; otherwise it returns 0.
160
161 If language is empty it will be determined heuristically. If code
162 contains the string "End Sub" it will be interpreted as VBScript,
163 otherwise as JScript. Additional script engines can be registered using
164 registerEngine().
165
166 You must add all the objects necessary (using addObject()) before
167 loading any scripts. If code declares a function that is already
168 available (no matter in which language) the first function is
169 overloaded and can no longer be called via call(); but it will still be
170 available by calling its script directly.
171
172 See also addObject(), scriptNames(), and functions().
173
175 name )
176 This is an overloaded member function, provided for convenience. It
177 behaves essentially like the above function.
178
179 Loads the source code from the file. The script can later be referred
180 to using its name which should not be empty.
181
182 The function returns a pointer to the script engine for the code in
183 file if file was loaded successfully; otherwise it returns 0.
184
185 The script engine used is determined from the file's extension. By
186 default ".js" files are interpreted as JScript files, and ".vbs" and
187 ".dsm" files are interpreted as VBScript. Additional script engines can
188 be registered using registerEngine().
189
191 extension, const QString & code = QString ( ) ) [static]
192 Registers the script engine called name and returns TRUE if the engine
193 was found; otherwise does nothing and returns FALSE.
194
195 The script engine will be used when loading files with the given
196 extension, or when loading source code that contains the string code.
197
199 Returns the script called name.
200
201 You can use the returned pointer to call functions directly through
202 QAxScript::call(), to access the script engine directly, or to delete
203 and thus unload the script.
204
206 Returns a file filter listing all the supported script languages. This
207 filter string is convenient for use with QFileDialog.
208
210 Returns a list with the names of all the scripts.
211
212
214 http://doc.trolltech.com/qaxscriptmanager.html
215 http://www.trolltech.com/faq/tech.html
216
218 Copyright 1992-2007 Trolltech ASA, http://www.trolltech.com. See the
219 license file included in the distribution for a complete license
220 statement.
221
223 Generated automatically from the source code.
224
226 If you find a bug in Qt, please report it as described in
227 http://doc.trolltech.com/bughowto.html. Good bug reports help us to
228 help you. Thank you.
229
230 The definitive Qt documentation is provided in HTML format; it is
231 located at $QTDIR/doc/html and can be read using Qt Assistant or with a
232 web browser. This man page is provided as a convenience for those users
233 who prefer man pages, although this format is not officially supported
234 by Trolltech.
235
236 If you find errors in this manual page, please report them to qt-
237 bugs@trolltech.com. Please include the name of the manual page
238 (qaxscriptmanager.3qt) and the Qt version (3.3.8).
239
240
241
242Trolltech AS 2 February 2007 QAxScriptManager(3qt)