source: trunk/doc/html/qaxscriptmanager.html@ 208

Last change on this file since 208 was 190, checked in by rudi, 14 years ago

reference documentation added

File size: 14.9 KB
Line 
1<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
2<!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/extensions/activeqt/container/qaxscript.cpp:867 -->
3<html>
4<head>
5<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
6<title>QAxScriptManager Class</title>
7<style type="text/css"><!--
8fn { margin-left: 1cm; text-indent: -1cm; }
9a:link { color: #004faf; text-decoration: none }
10a:visited { color: #672967; text-decoration: none }
11body { background: #ffffff; color: black; }
12--></style>
13</head>
14<body>
15
16<table border="0" cellpadding="0" cellspacing="0" width="100%">
17<tr bgcolor="#E5E5E5">
18<td valign=center>
19 <a href="index.html">
20<font color="#004faf">Home</font></a>
21 | <a href="classes.html">
22<font color="#004faf">All&nbsp;Classes</font></a>
23 | <a href="mainclasses.html">
24<font color="#004faf">Main&nbsp;Classes</font></a>
25 | <a href="annotated.html">
26<font color="#004faf">Annotated</font></a>
27 | <a href="groups.html">
28<font color="#004faf">Grouped&nbsp;Classes</font></a>
29 | <a href="functions.html">
30<font color="#004faf">Functions</font></a>
31</td>
32<td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>QAxScriptManager Class Reference<br><small>[<a href="qaxcontainer.html">QAxContainer module</a>]</small></h1>
33
34<p>The QAxScriptManager class provides a bridge between application objects
35and script code.
36<a href="#details">More...</a>
37<p>This class is part of the <b>Qt ActiveQt Extension</b>.
38<p><tt>#include &lt;<a href="qaxscript-h.html">qaxscript.h</a>&gt;</tt>
39<p>Inherits <a href="qobject.html">QObject</a>.
40<p><a href="qaxscriptmanager-members.html">List of all member functions.</a>
41<h2>Public Members</h2>
42<ul>
43<li class=fn><a href="#QAxScriptManager"><b>QAxScriptManager</b></a> ( QObject&nbsp;*&nbsp;parent = 0, const&nbsp;char&nbsp;*&nbsp;name = 0 )</li>
44<li class=fn><a href="#~QAxScriptManager"><b>~QAxScriptManager</b></a> ()</li>
45<li class=fn>void <a href="#addObject"><b>addObject</b></a> ( QAxBase&nbsp;*&nbsp;object )</li>
46<li class=fn>void <a href="#addObject-2"><b>addObject</b></a> ( QObject&nbsp;*&nbsp;object )</li>
47<li class=fn>QStringList <a href="#functions"><b>functions</b></a> ( QAxScript::FunctionFlags&nbsp;flags = QAxScript::FunctionNames ) const</li>
48<li class=fn>QStringList <a href="#scriptNames"><b>scriptNames</b></a> () const</li>
49<li class=fn>QAxScript * <a href="#script"><b>script</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;name ) const</li>
50<li class=fn>QAxScript * <a href="#load"><b>load</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;code, const&nbsp;QString&nbsp;&amp;&nbsp;name, const&nbsp;QString&nbsp;&amp;&nbsp;language )</li>
51<li class=fn>QAxScript * <a href="#load-2"><b>load</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;file, const&nbsp;QString&nbsp;&amp;&nbsp;name )</li>
52<li class=fn>QVariant <a href="#call"><b>call</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;function, const&nbsp;QVariant&nbsp;&amp;&nbsp;var1 = QVariant ( ), const&nbsp;QVariant&nbsp;&amp;&nbsp;var2 = QVariant ( ), const&nbsp;QVariant&nbsp;&amp;&nbsp;var3 = QVariant ( ), const&nbsp;QVariant&nbsp;&amp;&nbsp;var4 = QVariant ( ), const&nbsp;QVariant&nbsp;&amp;&nbsp;var5 = QVariant ( ), const&nbsp;QVariant&nbsp;&amp;&nbsp;var6 = QVariant ( ), const&nbsp;QVariant&nbsp;&amp;&nbsp;var7 = QVariant ( ), const&nbsp;QVariant&nbsp;&amp;&nbsp;var8 = QVariant ( ) )</li>
53<li class=fn>QVariant <a href="#call-2"><b>call</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;function, QValueList&lt;QVariant&gt;&nbsp;&amp;&nbsp;arguments )</li>
54</ul>
55<h2>Signals</h2>
56<ul>
57<li class=fn>void <a href="#error"><b>error</b></a> ( QAxScript&nbsp;*&nbsp;script, int&nbsp;code, const&nbsp;QString&nbsp;&amp;&nbsp;description, int&nbsp;sourcePosition, const&nbsp;QString&nbsp;&amp;&nbsp;sourceText )</li>
58</ul>
59<h2>Static Public Members</h2>
60<ul>
61<li class=fn>bool <a href="#registerEngine"><b>registerEngine</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;name, const&nbsp;QString&nbsp;&amp;&nbsp;extension, const&nbsp;QString&nbsp;&amp;&nbsp;code = QString ( ) )</li>
62<li class=fn>QString <a href="#scriptFileFilter"><b>scriptFileFilter</b></a> ()</li>
63</ul>
64<hr><a name="details"></a><h2>Detailed Description</h2>
65<p> This class is defined in the <b>Qt <a href="activeqt.html#ActiveQt">ActiveQt</a> Extension</b>, which can be found in the <tt>qt/extensions</tt> directory. It is not included in the main Qt API.
66<p>
67
68The QAxScriptManager class provides a bridge between application objects
69and script code.
70
71
72<p> The QAxScriptManager acts as a bridge between the COM objects embedded
73in the Qt application through <a href="qaxobject.html">QAxObject</a> or <a href="qaxwidget.html">QAxWidget</a>, and the scripting
74languages available through the Windows Script technologies, usually JScript
75and VBScript.
76<p> Create one QAxScriptManager for each separate document in your
77application, and add the COM objects the scripts need to access
78using <a href="#addObject">addObject</a>(). Then <a href="#load">load</a>() the script sources and invoke the
79functions using <a href="#call">call</a>().
80<p> <b>Warning:</b> This class is not available with the bcc5.5 and MingW
81compilers.
82
83<hr><h2>Member Function Documentation</h2>
84<h3 class=fn><a name="QAxScriptManager"></a>QAxScriptManager::QAxScriptManager ( <a href="qobject.html">QObject</a>&nbsp;*&nbsp;parent = 0, const&nbsp;char&nbsp;*&nbsp;name = 0 )
85</h3>
86Creates a QAxScriptManager object. <em>parent</em> and <em>name</em> are passed
87on to the <a href="qobject.html">QObject</a> constructor.
88<p> It is usual to create one QAxScriptManager for each document in an
89application.
90
91<h3 class=fn><a name="~QAxScriptManager"></a>QAxScriptManager::~QAxScriptManager ()
92</h3>
93Destroys the objects, releasing all allocated resources.
94
95<h3 class=fn>void <a name="addObject"></a>QAxScriptManager::addObject ( <a href="qaxbase.html">QAxBase</a>&nbsp;*&nbsp;object )
96</h3>
97Adds <em>object</em> to the manager. Scripts handled by this
98manager can access the object in the code using the object's <a href="qobject.html#name-prop">name</a> property.
99<p> You must add all the necessary objects before loading any scripts.
100
101<h3 class=fn>void <a name="addObject-2"></a>QAxScriptManager::addObject ( <a href="qobject.html">QObject</a>&nbsp;*&nbsp;object )
102</h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
103<p> Adds a generic COM wrapper for <em>object</em> to the manager. <em>object</em>
104must be exposed as a COM object using the functionality provided
105by the <a href="qaxserver.html">QAxServer module.</a>. Applications
106using this function you must link against the qaxserver library.
107
108<h3 class=fn><a href="qvariant.html">QVariant</a> <a name="call"></a>QAxScriptManager::call ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;function, const&nbsp;<a href="qvariant.html">QVariant</a>&nbsp;&amp;&nbsp;var1 = QVariant ( ), const&nbsp;<a href="qvariant.html">QVariant</a>&nbsp;&amp;&nbsp;var2 = QVariant ( ), const&nbsp;<a href="qvariant.html">QVariant</a>&nbsp;&amp;&nbsp;var3 = QVariant ( ), const&nbsp;<a href="qvariant.html">QVariant</a>&nbsp;&amp;&nbsp;var4 = QVariant ( ), const&nbsp;<a href="qvariant.html">QVariant</a>&nbsp;&amp;&nbsp;var5 = QVariant ( ), const&nbsp;<a href="qvariant.html">QVariant</a>&nbsp;&amp;&nbsp;var6 = QVariant ( ), const&nbsp;<a href="qvariant.html">QVariant</a>&nbsp;&amp;&nbsp;var7 = QVariant ( ), const&nbsp;<a href="qvariant.html">QVariant</a>&nbsp;&amp;&nbsp;var8 = QVariant ( ) )
109</h3>
110Calls <em>function</em>, passing the parameters <em>var1</em>, <em>var1</em>,
111<em>var2</em>, <em>var3</em>, <em>var4</em>, <em>var5</em>, <em>var6</em>, <em>var7</em> and <em>var8</em>
112as arguments and returns the value returned by the function, or an
113invalid <a href="qvariant.html">QVariant</a> if the function does not return a value or when
114the function call failed. The call returns when the script's
115execution has finished.
116<p> In most script engines the only supported parameter type is "const
117QVariant&", for example, to call a JavaScript function
118<pre>
119 function setNumber(number)
120 {
121 n = number;
122 }
123 </pre>
124
125use
126<pre>
127 <a href="qvaluelist.html">QValueList</a> args;
128 args &lt;&lt; 5;
129 script-&gt;call("setNumber(const <a href="qvariant.html">QVariant</a>&amp;)", args);
130 </pre>
131
132As with <a href="qaxbase.html#dynamicCall">dynamicCall</a> the
133parameters can directly be embedded in the function string.
134<pre>
135 script-&gt;call("setNumber(5)");
136 </pre>
137
138However, this is slower.
139<p> Functions provided by script engines that don't support
140introspection are not available and must be called directly
141using <a href="qaxscript.html#call">QAxScript::call</a>() on the respective <a href="#script">script</a> object.
142<p> Note that calling this function can be significantely slower than
143using <a href="#call">call</a>() on the respective <a href="qaxscript.html">QAxScript</a> directly.
144
145<h3 class=fn><a href="qvariant.html">QVariant</a> <a name="call-2"></a>QAxScriptManager::call ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;function, <a href="qvaluelist.html">QValueList</a>&lt;QVariant&gt;&nbsp;&amp;&nbsp;arguments )
146</h3> This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
147<p> Calls <em>function</em> passing <em>arguments</em> as parameters, and returns
148the result. Returns when the script's execution has finished.
149
150<h3 class=fn>void <a name="error"></a>QAxScriptManager::error ( <a href="qaxscript.html">QAxScript</a>&nbsp;*&nbsp;script, int&nbsp;code, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;description, int&nbsp;sourcePosition, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;sourceText )<tt> [signal]</tt>
151</h3>
152
153<p> This signal is emitted when an execution error occured while
154running <em>script</em>.
155<p> <em>code</em>, <em>description</em>, <em>sourcePosition</em> and <em>sourceText</em>
156contain information about the execution error.
157
158<h3 class=fn><a href="qstringlist.html">QStringList</a> <a name="functions"></a>QAxScriptManager::functions ( <a href="qaxscript.html#FunctionFlags-enum">QAxScript::FunctionFlags</a>&nbsp;flags = QAxScript::FunctionNames ) const
159</h3>
160Returns a list with all the functions that are available.
161Functions provided by script engines that don't support
162introspection are not included in the list.
163The functions are either provided with full prototypes or
164only as names, depending on the value of <em>flags</em>.
165
166<h3 class=fn><a href="qaxscript.html">QAxScript</a>&nbsp;* <a name="load"></a>QAxScriptManager::load ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;code, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;name, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;language )
167</h3>
168Loads the script source <em>code</em> using the script engine for <em>language</em>. The script can later be referred to using its <em>name</em>
169which should not be empty.
170<p> The function returns a pointer to the script for the given
171<em>code</em> if the <em>code</em> was loaded successfully; otherwise it
172returns 0.
173<p> If <em>language</em> is empty it will be determined heuristically. If <em>code</em> contains the string "End Sub" it will be interpreted as
174VBScript, otherwise as JScript. Additional script engines can be
175registered using <a href="#registerEngine">registerEngine</a>().
176<p> You must add all the objects necessary (using <a href="#addObject">addObject</a>()) <em>before</em> loading any scripts. If <em>code</em> declares a function that is
177already available (no matter in which language) the first function
178is overloaded and can no longer be called via <a href="#call">call</a>(); but it will
179still be available by calling its <a href="#script">script</a>
180directly.
181<p> <p>See also <a href="#addObject">addObject</a>(), <a href="#scriptNames">scriptNames</a>(), and <a href="#functions">functions</a>().
182
183<h3 class=fn><a href="qaxscript.html">QAxScript</a>&nbsp;* <a name="load-2"></a>QAxScriptManager::load ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;file, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;name )
184</h3>
185This is an overloaded member function, provided for convenience. It behaves essentially like the above function.
186<p> Loads the source code from the <em>file</em>. The script can later be
187referred to using its <em>name</em> which should not be empty.
188<p> The function returns a pointer to the script engine for the code
189in <em>file</em> if <em>file</em> was loaded successfully; otherwise it
190returns 0.
191<p> The script engine used is determined from the file's extension. By
192default ".js" files are interpreted as JScript files, and ".vbs"
193and ".dsm" files are interpreted as VBScript. Additional script
194engines can be registered using <a href="#registerEngine">registerEngine</a>().
195
196<h3 class=fn>bool <a name="registerEngine"></a>QAxScriptManager::registerEngine ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;name, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;extension, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;code = QString ( ) )<tt> [static]</tt>
197</h3>
198Registers the script engine called <em>name</em> and returns TRUE if the
199engine was found; otherwise does nothing and returns FALSE.
200<p> The script engine will be used when loading files with the given
201<em>extension</em>, or when loading source code that contains the string
202<em>code</em>.
203
204<h3 class=fn><a href="qaxscript.html">QAxScript</a>&nbsp;* <a name="script"></a>QAxScriptManager::script ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;name ) const
205</h3>
206Returns the script called <em>name</em>.
207<p> You can use the returned pointer to call functions directly
208through <a href="qaxscript.html#call">QAxScript::call</a>(), to access the script engine directly, or
209to delete and thus unload the script.
210
211<h3 class=fn><a href="qstring.html">QString</a> <a name="scriptFileFilter"></a>QAxScriptManager::scriptFileFilter ()<tt> [static]</tt>
212</h3>
213Returns a file filter listing all the supported script languages.
214This filter string is convenient for use with <a href="qfiledialog.html">QFileDialog</a>.
215
216<h3 class=fn><a href="qstringlist.html">QStringList</a> <a name="scriptNames"></a>QAxScriptManager::scriptNames () const
217</h3>
218Returns a list with the names of all the scripts.
219
220<!-- eof -->
221<hr><p>
222This file is part of the <a href="index.html">Qt toolkit</a>.
223Copyright &copy; 1995-2007
224<a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center>
225<table width=100% cellspacing=0 border=0><tr>
226<td>Copyright &copy; 2007
227<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
228<td align=right><div align=right>Qt 3.3.8</div>
229</table></div></address></body>
230</html>
Note: See TracBrowser for help on using the repository browser.