[190] | 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"><!--
|
---|
| 8 | fn { margin-left: 1cm; text-indent: -1cm; }
|
---|
| 9 | a:link { color: #004faf; text-decoration: none }
|
---|
| 10 | a:visited { color: #672967; text-decoration: none }
|
---|
| 11 | body { 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 Classes</font></a>
|
---|
| 23 | | <a href="mainclasses.html">
|
---|
| 24 | <font color="#004faf">Main 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 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
|
---|
| 35 | and 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 <<a href="qaxscript-h.html">qaxscript.h</a>></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 * parent = 0, const char * 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 * object )</li>
|
---|
| 46 | <li class=fn>void <a href="#addObject-2"><b>addObject</b></a> ( QObject * object )</li>
|
---|
| 47 | <li class=fn>QStringList <a href="#functions"><b>functions</b></a> ( QAxScript::FunctionFlags 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 QString & name ) const</li>
|
---|
| 50 | <li class=fn>QAxScript * <a href="#load"><b>load</b></a> ( const QString & code, const QString & name, const QString & language )</li>
|
---|
| 51 | <li class=fn>QAxScript * <a href="#load-2"><b>load</b></a> ( const QString & file, const QString & name )</li>
|
---|
| 52 | <li class=fn>QVariant <a href="#call"><b>call</b></a> ( 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 ( ) )</li>
|
---|
| 53 | <li class=fn>QVariant <a href="#call-2"><b>call</b></a> ( const QString & function, QValueList<QVariant> & arguments )</li>
|
---|
| 54 | </ul>
|
---|
| 55 | <h2>Signals</h2>
|
---|
| 56 | <ul>
|
---|
| 57 | <li class=fn>void <a href="#error"><b>error</b></a> ( QAxScript * script, int code, const QString & description, int sourcePosition, const QString & 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 QString & name, const QString & extension, const QString & 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 |
|
---|
| 68 | The QAxScriptManager class provides a bridge between application objects
|
---|
| 69 | and script code.
|
---|
| 70 |
|
---|
| 71 |
|
---|
| 72 | <p> The QAxScriptManager acts as a bridge between the COM objects embedded
|
---|
| 73 | in the Qt application through <a href="qaxobject.html">QAxObject</a> or <a href="qaxwidget.html">QAxWidget</a>, and the scripting
|
---|
| 74 | languages available through the Windows Script technologies, usually JScript
|
---|
| 75 | and VBScript.
|
---|
| 76 | <p> Create one QAxScriptManager for each separate document in your
|
---|
| 77 | application, and add the COM objects the scripts need to access
|
---|
| 78 | using <a href="#addObject">addObject</a>(). Then <a href="#load">load</a>() the script sources and invoke the
|
---|
| 79 | functions using <a href="#call">call</a>().
|
---|
| 80 | <p> <b>Warning:</b> This class is not available with the bcc5.5 and MingW
|
---|
| 81 | compilers.
|
---|
| 82 |
|
---|
| 83 | <hr><h2>Member Function Documentation</h2>
|
---|
| 84 | <h3 class=fn><a name="QAxScriptManager"></a>QAxScriptManager::QAxScriptManager ( <a href="qobject.html">QObject</a> * parent = 0, const char * name = 0 )
|
---|
| 85 | </h3>
|
---|
| 86 | Creates a QAxScriptManager object. <em>parent</em> and <em>name</em> are passed
|
---|
| 87 | on to the <a href="qobject.html">QObject</a> constructor.
|
---|
| 88 | <p> It is usual to create one QAxScriptManager for each document in an
|
---|
| 89 | application.
|
---|
| 90 |
|
---|
| 91 | <h3 class=fn><a name="~QAxScriptManager"></a>QAxScriptManager::~QAxScriptManager ()
|
---|
| 92 | </h3>
|
---|
| 93 | Destroys the objects, releasing all allocated resources.
|
---|
| 94 |
|
---|
| 95 | <h3 class=fn>void <a name="addObject"></a>QAxScriptManager::addObject ( <a href="qaxbase.html">QAxBase</a> * object )
|
---|
| 96 | </h3>
|
---|
| 97 | Adds <em>object</em> to the manager. Scripts handled by this
|
---|
| 98 | manager 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> * 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>
|
---|
| 104 | must be exposed as a COM object using the functionality provided
|
---|
| 105 | by the <a href="qaxserver.html">QAxServer module.</a>. Applications
|
---|
| 106 | using 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 <a href="qstring.html">QString</a> & function, const <a href="qvariant.html">QVariant</a> & var1 = QVariant ( ), const <a href="qvariant.html">QVariant</a> & var2 = QVariant ( ), const <a href="qvariant.html">QVariant</a> & var3 = QVariant ( ), const <a href="qvariant.html">QVariant</a> & var4 = QVariant ( ), const <a href="qvariant.html">QVariant</a> & var5 = QVariant ( ), const <a href="qvariant.html">QVariant</a> & var6 = QVariant ( ), const <a href="qvariant.html">QVariant</a> & var7 = QVariant ( ), const <a href="qvariant.html">QVariant</a> & var8 = QVariant ( ) )
|
---|
| 109 | </h3>
|
---|
| 110 | Calls <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>
|
---|
| 112 | as arguments and returns the value returned by the function, or an
|
---|
| 113 | invalid <a href="qvariant.html">QVariant</a> if the function does not return a value or when
|
---|
| 114 | the function call failed. The call returns when the script's
|
---|
| 115 | execution has finished.
|
---|
| 116 | <p> In most script engines the only supported parameter type is "const
|
---|
| 117 | QVariant&", for example, to call a JavaScript function
|
---|
| 118 | <pre>
|
---|
| 119 | function setNumber(number)
|
---|
| 120 | {
|
---|
| 121 | n = number;
|
---|
| 122 | }
|
---|
| 123 | </pre>
|
---|
| 124 |
|
---|
| 125 | use
|
---|
| 126 | <pre>
|
---|
| 127 | <a href="qvaluelist.html">QValueList</a> args;
|
---|
| 128 | args << 5;
|
---|
| 129 | script->call("setNumber(const <a href="qvariant.html">QVariant</a>&)", args);
|
---|
| 130 | </pre>
|
---|
| 131 |
|
---|
| 132 | As with <a href="qaxbase.html#dynamicCall">dynamicCall</a> the
|
---|
| 133 | parameters can directly be embedded in the function string.
|
---|
| 134 | <pre>
|
---|
| 135 | script->call("setNumber(5)");
|
---|
| 136 | </pre>
|
---|
| 137 |
|
---|
| 138 | However, this is slower.
|
---|
| 139 | <p> Functions provided by script engines that don't support
|
---|
| 140 | introspection are not available and must be called directly
|
---|
| 141 | using <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
|
---|
| 143 | using <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 <a href="qstring.html">QString</a> & function, <a href="qvaluelist.html">QValueList</a><QVariant> & 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
|
---|
| 148 | the 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> * script, int code, const <a href="qstring.html">QString</a> & description, int sourcePosition, const <a href="qstring.html">QString</a> & sourceText )<tt> [signal]</tt>
|
---|
| 151 | </h3>
|
---|
| 152 |
|
---|
| 153 | <p> This signal is emitted when an execution error occured while
|
---|
| 154 | running <em>script</em>.
|
---|
| 155 | <p> <em>code</em>, <em>description</em>, <em>sourcePosition</em> and <em>sourceText</em>
|
---|
| 156 | contain 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> flags = QAxScript::FunctionNames ) const
|
---|
| 159 | </h3>
|
---|
| 160 | Returns a list with all the functions that are available.
|
---|
| 161 | Functions provided by script engines that don't support
|
---|
| 162 | introspection are not included in the list.
|
---|
| 163 | The functions are either provided with full prototypes or
|
---|
| 164 | only as names, depending on the value of <em>flags</em>.
|
---|
| 165 |
|
---|
| 166 | <h3 class=fn><a href="qaxscript.html">QAxScript</a> * <a name="load"></a>QAxScriptManager::load ( const <a href="qstring.html">QString</a> & code, const <a href="qstring.html">QString</a> & name, const <a href="qstring.html">QString</a> & language )
|
---|
| 167 | </h3>
|
---|
| 168 | Loads 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>
|
---|
| 169 | which 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
|
---|
| 172 | returns 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
|
---|
| 174 | VBScript, otherwise as JScript. Additional script engines can be
|
---|
| 175 | registered 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
|
---|
| 177 | already available (no matter in which language) the first function
|
---|
| 178 | is overloaded and can no longer be called via <a href="#call">call</a>(); but it will
|
---|
| 179 | still be available by calling its <a href="#script">script</a>
|
---|
| 180 | directly.
|
---|
| 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> * <a name="load-2"></a>QAxScriptManager::load ( const <a href="qstring.html">QString</a> & file, const <a href="qstring.html">QString</a> & name )
|
---|
| 184 | </h3>
|
---|
| 185 | This 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
|
---|
| 187 | referred 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
|
---|
| 189 | in <em>file</em> if <em>file</em> was loaded successfully; otherwise it
|
---|
| 190 | returns 0.
|
---|
| 191 | <p> The script engine used is determined from the file's extension. By
|
---|
| 192 | default ".js" files are interpreted as JScript files, and ".vbs"
|
---|
| 193 | and ".dsm" files are interpreted as VBScript. Additional script
|
---|
| 194 | engines can be registered using <a href="#registerEngine">registerEngine</a>().
|
---|
| 195 |
|
---|
| 196 | <h3 class=fn>bool <a name="registerEngine"></a>QAxScriptManager::registerEngine ( const <a href="qstring.html">QString</a> & name, const <a href="qstring.html">QString</a> & extension, const <a href="qstring.html">QString</a> & code = QString ( ) )<tt> [static]</tt>
|
---|
| 197 | </h3>
|
---|
| 198 | Registers the script engine called <em>name</em> and returns TRUE if the
|
---|
| 199 | engine 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> * <a name="script"></a>QAxScriptManager::script ( const <a href="qstring.html">QString</a> & name ) const
|
---|
| 205 | </h3>
|
---|
| 206 | Returns the script called <em>name</em>.
|
---|
| 207 | <p> You can use the returned pointer to call functions directly
|
---|
| 208 | through <a href="qaxscript.html#call">QAxScript::call</a>(), to access the script engine directly, or
|
---|
| 209 | to 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>
|
---|
| 213 | Returns a file filter listing all the supported script languages.
|
---|
| 214 | This 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>
|
---|
| 218 | Returns a list with the names of all the scripts.
|
---|
| 219 |
|
---|
| 220 | <!-- eof -->
|
---|
| 221 | <hr><p>
|
---|
| 222 | This file is part of the <a href="index.html">Qt toolkit</a>.
|
---|
| 223 | Copyright © 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 © 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>
|
---|