1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208
|
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en_US" lang="en_US">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- qaxscript.cpp -->
<title>Qt 4.8: QAxScriptManager Class Reference</title>
<link rel="stylesheet" type="text/css" href="style/offline.css" />
</head>
<body>
<div class="header" id="qtdocheader">
<div class="content">
<a href="index.html" class="qtref"><span>Qt Reference Documentation</span></a>
</div>
<div class="breadcrumb toolblock">
<ul>
<li class="first"><a href="index.html">Home</a></li>
<!-- Breadcrumbs go here -->
<li><a href="modules.html">Modules</a></li>
<li><a href="qaxcontainer.html">QAxContainer</a></li>
<li>QAxScriptManager</li>
</ul>
</div>
</div>
<div class="content mainContent">
<div class="toc">
<h3><a name="toc">Contents</a></h3>
<ul>
<li class="level1"><a href="#public-functions">Public Functions</a></li>
<li class="level1"><a href="#signals">Signals</a></li>
<li class="level1"><a href="#static-public-members">Static Public Members</a></li>
<li class="level1"><a href="#details">Detailed Description</a></li>
</ul>
</div>
<h1 class="title">QAxScriptManager Class Reference</h1>
<!-- $$$QAxScriptManager-brief -->
<p>The QAxScriptManager class provides a bridge between application objects and script code. <a href="#details">More...</a></p>
<!-- @@@QAxScriptManager -->
<pre class="cpp"> <span class="preprocessor">#include <QAxScriptManager></span></pre><p><b>Inherits: </b><a href="qobject.html">QObject</a>.</p>
<ul>
<li><a href="qaxscriptmanager-members.html">List of all members, including inherited members</a></li>
</ul>
<a name="public-functions"></a>
<h2>Public Functions</h2>
<table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qaxscriptmanager.html#QAxScriptManager">QAxScriptManager</a></b> ( QObject * <i>parent</i> = 0 )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qaxscriptmanager.html#dtor.QAxScriptManager">~QAxScriptManager</a></b> ()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qaxscriptmanager.html#addObject">addObject</a></b> ( QAxBase * <i>object</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qaxscriptmanager.html#addObject-2">addObject</a></b> ( QObject * <i>object</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QVariant </td><td class="memItemRight bottomAlign"><b><a href="qaxscriptmanager.html#call">call</a></b> ( const QString & <i>function</i>, const QVariant & <i>var1</i> = QVariant(), const QVariant & <i>var2</i> = QVariant(), const QVariant & <i>var3</i> = QVariant(), const QVariant & <i>var4</i> = QVariant(), const QVariant & <i>var5</i> = QVariant(), const QVariant & <i>var6</i> = QVariant(), const QVariant & <i>var7</i> = QVariant(), const QVariant & <i>var8</i> = QVariant() )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QVariant </td><td class="memItemRight bottomAlign"><b><a href="qaxscriptmanager.html#call-2">call</a></b> ( const QString & <i>function</i>, QList<QVariant> & <i>arguments</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QStringList </td><td class="memItemRight bottomAlign"><b><a href="qaxscriptmanager.html#functions">functions</a></b> ( QAxScript::FunctionFlags <i>flags</i> = QAxScript::FunctionNames ) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QAxScript * </td><td class="memItemRight bottomAlign"><b><a href="qaxscriptmanager.html#load">load</a></b> ( const QString & <i>code</i>, const QString & <i>name</i>, const QString & <i>language</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QAxScript * </td><td class="memItemRight bottomAlign"><b><a href="qaxscriptmanager.html#load-2">load</a></b> ( const QString & <i>file</i>, const QString & <i>name</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QAxScript * </td><td class="memItemRight bottomAlign"><b><a href="qaxscriptmanager.html#script">script</a></b> ( const QString & <i>name</i> ) const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QStringList </td><td class="memItemRight bottomAlign"><b><a href="qaxscriptmanager.html#scriptNames">scriptNames</a></b> () const</td></tr>
</table>
<ul>
<li class="fn">29 public functions inherited from <a href="qobject.html#public-functions">QObject</a></li>
</ul>
<a name="signals"></a>
<h2>Signals</h2>
<table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qaxscriptmanager.html#error">error</a></b> ( QAxScript * <i>script</i>, int <i>code</i>, const QString & <i>description</i>, int <i>sourcePosition</i>, const QString & <i>sourceText</i> )</td></tr>
</table>
<ul>
<li class="fn">1 signal inherited from <a href="qobject.html#signals">QObject</a></li>
</ul>
<a name="static-public-members"></a>
<h2>Static Public Members</h2>
<table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qaxscriptmanager.html#registerEngine">registerEngine</a></b> ( const QString & <i>name</i>, const QString & <i>extension</i>, const QString & <i>code</i> = QString() )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QString </td><td class="memItemRight bottomAlign"><b><a href="qaxscriptmanager.html#scriptFileFilter">scriptFileFilter</a></b> ()</td></tr>
</table>
<ul>
<li class="fn">7 static public members inherited from <a href="qobject.html#static-public-members">QObject</a></li>
</ul>
<h3>Additional Inherited Members</h3>
<ul>
<li class="fn">1 property inherited from <a href="qobject.html#properties">QObject</a></li>
<li class="fn">1 public slot inherited from <a href="qobject.html#public-slots">QObject</a></li>
<li class="fn">8 protected functions inherited from <a href="qobject.html#protected-functions">QObject</a></li>
</ul>
<a name="details"></a>
<!-- $$$QAxScriptManager-description -->
<div class="descr">
<h2>Detailed Description</h2>
<p>The QAxScriptManager class provides a bridge between application objects and script code.</p>
<p>The QAxScriptManager acts as a bridge between the COM objects embedded in the Qt application through <a href="qaxobject.html">QAxObject</a> or <a href="qaxwidget.html">QAxWidget</a>, and the scripting languages available through the Windows Script technologies, usually JScript and VBScript.</p>
<p>Create one QAxScriptManager for each separate document in your application, and add the COM objects the scripts need to access using <a href="qaxscriptmanager.html#addObject">addObject</a>(). Then <a href="qaxscriptmanager.html#load">load</a>() the script sources and invoke the functions using <a href="qaxscriptmanager.html#call">call</a>().</p>
<p><b>Warning:</b> This class is not available with the bcc5.5 and MingW compilers.</p>
</div>
<p><b>See also </b><a href="qaxscript.html">QAxScript</a>, <a href="qaxscriptengine.html">QAxScriptEngine</a>, <a href="qaxbase.html">QAxBase</a>, and <a href="activeqt.html#activeqt-framework">ActiveQt Framework</a>.</p>
<!-- @@@QAxScriptManager -->
<div class="func">
<h2>Member Function Documentation</h2>
<!-- $$$QAxScriptManager[overload1]$$$QAxScriptManagerQObject* -->
<h3 class="fn"><a name="QAxScriptManager"></a>QAxScriptManager::<span class="name">QAxScriptManager</span> ( <span class="type"><a href="qobject.html">QObject</a></span> * <i>parent</i> = 0 )</h3>
<p>Creates a <a href="qaxscriptmanager.html">QAxScriptManager</a> object. <i>parent</i> is passed on to the <a href="qobject.html">QObject</a> constructor.</p>
<p>It is usual to create one <a href="qaxscriptmanager.html">QAxScriptManager</a> for each document in an application.</p>
<!-- @@@QAxScriptManager -->
<!-- $$$~QAxScriptManager[overload1]$$$~QAxScriptManager -->
<h3 class="fn"><a name="dtor.QAxScriptManager"></a>QAxScriptManager::<span class="name">~QAxScriptManager</span> ()</h3>
<p>Destroys the objects, releasing all allocated resources.</p>
<!-- @@@~QAxScriptManager -->
<!-- $$$addObject[overload1]$$$addObjectQAxBase* -->
<h3 class="fn"><a name="addObject"></a><span class="type">void</span> QAxScriptManager::<span class="name">addObject</span> ( <span class="type"><a href="qaxbase.html">QAxBase</a></span> * <i>object</i> )</h3>
<p>Adds <i>object</i> to the manager. Scripts handled by this manager can access the object in the code using the object's <a href="qobject.html#objectName-prop">objectName</a> property.</p>
<p>You must add all the necessary objects before loading any scripts.</p>
<!-- @@@addObject -->
<!-- $$$addObject$$$addObjectQObject* -->
<h3 class="fn"><a name="addObject-2"></a><span class="type">void</span> QAxScriptManager::<span class="name">addObject</span> ( <span class="type"><a href="qobject.html">QObject</a></span> * <i>object</i> )</h3>
<p>This is an overloaded function.</p>
<p>Adds a generic COM wrapper for <i>object</i> to the manager. <i>object</i> must be exposed as a COM object using the functionality provided by the <a href="qaxserver.html">QAxServer</a> module. Applications using this function you must link against the qaxserver library.</p>
<!-- @@@addObject -->
<!-- $$$call[overload1]$$$callconstQString&constQVariant&constQVariant&constQVariant&constQVariant&constQVariant&constQVariant&constQVariant&constQVariant& -->
<h3 class="fn"><a name="call"></a><span class="type"><a href="qvariant.html">QVariant</a></span> QAxScriptManager::<span class="name">call</span> ( const <span class="type"><a href="qstring.html">QString</a></span> & <i>function</i>, const <span class="type"><a href="qvariant.html">QVariant</a></span> & <i>var1</i> = QVariant(), const <span class="type"><a href="qvariant.html">QVariant</a></span> & <i>var2</i> = QVariant(), const <span class="type"><a href="qvariant.html">QVariant</a></span> & <i>var3</i> = QVariant(), const <span class="type"><a href="qvariant.html">QVariant</a></span> & <i>var4</i> = QVariant(), const <span class="type"><a href="qvariant.html">QVariant</a></span> & <i>var5</i> = QVariant(), const <span class="type"><a href="qvariant.html">QVariant</a></span> & <i>var6</i> = QVariant(), const <span class="type"><a href="qvariant.html">QVariant</a></span> & <i>var7</i> = QVariant(), const <span class="type"><a href="qvariant.html">QVariant</a></span> & <i>var8</i> = QVariant() )</h3>
<p>Calls <i>function</i>, passing the parameters <i>var1</i>, <i>var1</i>, <i>var2</i>, <i>var3</i>, <i>var4</i>, <i>var5</i>, <i>var6</i>, <i>var7</i> and <i>var8</i> as arguments and returns the value returned by the function, or an invalid <a href="qvariant.html">QVariant</a> if the function does not return a value or when the function call failed. The call returns when the script's execution has finished.</p>
<p>In most script engines the only supported parameter type is "const <a href="qvariant.html">QVariant</a>&", for example, to call a JavaScript function</p>
<pre class="cpp"> function setNumber(number)
{
n <span class="operator">=</span> number;
}</pre>
<p>use</p>
<pre class="cpp"> <span class="type">QValueList</span> args;
args <span class="operator"><</span><span class="operator"><</span> <span class="number">5</span>;
script<span class="operator">-</span><span class="operator">></span>call(<span class="string">"setNumber(const QVariant&)"</span><span class="operator">,</span> args);</pre>
<p>As with <a href="qaxbase.html#dynamicCall">dynamicCall</a> the parameters can directly be embedded in the function string.</p>
<pre class="cpp"> script<span class="operator">-</span><span class="operator">></span>call(<span class="string">"setNumber(5)"</span>);</pre>
<p>However, this is slower.</p>
<p>Functions provided by script engines that don't support introspection are not available and must be called directly using <a href="qaxscript.html#call">QAxScript::call</a>() on the respective <a href="qaxscriptmanager.html#script">script</a> object.</p>
<p>Note that calling this function can be significantely slower than using call() on the respective <a href="qaxscript.html">QAxScript</a> directly.</p>
<!-- @@@call -->
<!-- $$$call$$$callconstQString&QList<QVariant>& -->
<h3 class="fn"><a name="call-2"></a><span class="type"><a href="qvariant.html">QVariant</a></span> QAxScriptManager::<span class="name">call</span> ( const <span class="type"><a href="qstring.html">QString</a></span> & <i>function</i>, <span class="type"><a href="qlist.html">QList</a></span><<span class="type"><a href="qvariant.html">QVariant</a></span>> & <i>arguments</i> )</h3>
<p>This is an overloaded function.</p>
<p>Calls <i>function</i> passing <i>arguments</i> as parameters, and returns the result. Returns when the script's execution has finished.</p>
<!-- @@@call -->
<!-- $$$error[overload1]$$$errorQAxScript*intconstQString&intconstQString& -->
<h3 class="fn"><a name="error"></a><span class="type">void</span> QAxScriptManager::<span class="name">error</span> ( <span class="type"><a href="qaxscript.html">QAxScript</a></span> * <i>script</i>, <span class="type">int</span> <i>code</i>, const <span class="type"><a href="qstring.html">QString</a></span> & <i>description</i>, <span class="type">int</span> <i>sourcePosition</i>, const <span class="type"><a href="qstring.html">QString</a></span> & <i>sourceText</i> )<tt> [signal]</tt></h3>
<p>This signal is emitted when an execution error occurred while running <i>script</i>.</p>
<p><i>code</i>, <i>description</i>, <i>sourcePosition</i> and <i>sourceText</i> contain information about the execution error.</p>
<p><b>Warning:</b> Do not delete <i>script</i> in a slot connected to this signal. Use <a href="qobject.html#deleteLater">deleteLater</a>() instead.</p>
<!-- @@@error -->
<!-- $$$functions[overload1]$$$functionsQAxScript::FunctionFlags -->
<h3 class="fn"><a name="functions"></a><span class="type"><a href="qstringlist.html">QStringList</a></span> QAxScriptManager::<span class="name">functions</span> ( <span class="type"><a href="qaxscript.html#FunctionFlags-enum">QAxScript::FunctionFlags</a></span> <i>flags</i> = QAxScript::FunctionNames ) const</h3>
<p>Returns a list with all the functions that are available. Functions provided by script engines that don't support introspection are not included in the list. The functions are either provided with full prototypes or only as names, depending on the value of <i>flags</i>.</p>
<!-- @@@functions -->
<!-- $$$load[overload1]$$$loadconstQString&constQString&constQString& -->
<h3 class="fn"><a name="load"></a><span class="type"><a href="qaxscript.html">QAxScript</a></span> * QAxScriptManager::<span class="name">load</span> ( const <span class="type"><a href="qstring.html">QString</a></span> & <i>code</i>, const <span class="type"><a href="qstring.html">QString</a></span> & <i>name</i>, const <span class="type"><a href="qstring.html">QString</a></span> & <i>language</i> )</h3>
<p>Loads the script source <i>code</i> using the script engine for <i>language</i>. The script can later be referred to using its <i>name</i> which should not be empty.</p>
<p>The function returns a pointer to the script for the given <i>code</i> if the <i>code</i> was loaded successfully; otherwise it returns 0.</p>
<p>If <i>language</i> is empty it will be determined heuristically. If <i>code</i> contains the string "End Sub" it will be interpreted as VBScript, otherwise as JScript. Additional script engines can be registered using <a href="qaxscriptmanager.html#registerEngine">registerEngine</a>().</p>
<p>You must add all the objects necessary (using <a href="qaxscriptmanager.html#addObject">addObject</a>()) <i>before</i> loading any scripts. If <i>code</i> declares a function that is already available (no matter in which language) the first function is overloaded and can no longer be called via <a href="qaxscriptmanager.html#call">call</a>(); but it will still be available by calling its <a href="qaxscriptmanager.html#script">script</a> directly.</p>
<p><b>See also </b><a href="qaxscriptmanager.html#addObject">addObject</a>(), <a href="qaxscriptmanager.html#scriptNames">scriptNames</a>(), and <a href="qaxscriptmanager.html#functions">functions</a>().</p>
<!-- @@@load -->
<!-- $$$load$$$loadconstQString&constQString& -->
<h3 class="fn"><a name="load-2"></a><span class="type"><a href="qaxscript.html">QAxScript</a></span> * QAxScriptManager::<span class="name">load</span> ( const <span class="type"><a href="qstring.html">QString</a></span> & <i>file</i>, const <span class="type"><a href="qstring.html">QString</a></span> & <i>name</i> )</h3>
<p>This is an overloaded function.</p>
<p>Loads the source code from the <i>file</i>. The script can later be referred to using its <i>name</i> which should not be empty.</p>
<p>The function returns a pointer to the script engine for the code in <i>file</i> if <i>file</i> was loaded successfully; otherwise it returns 0.</p>
<p>The script engine used is determined from the file's extension. By default ".js" files are interpreted as JScript files, and ".vbs" and ".dsm" files are interpreted as VBScript. Additional script engines can be registered using <a href="qaxscriptmanager.html#registerEngine">registerEngine</a>().</p>
<!-- @@@load -->
<!-- $$$registerEngine[overload1]$$$registerEngineconstQString&constQString&constQString& -->
<h3 class="fn"><a name="registerEngine"></a><span class="type">bool</span> QAxScriptManager::<span class="name">registerEngine</span> ( const <span class="type"><a href="qstring.html">QString</a></span> & <i>name</i>, const <span class="type"><a href="qstring.html">QString</a></span> & <i>extension</i>, const <span class="type"><a href="qstring.html">QString</a></span> & <i>code</i> = QString() )<tt> [static]</tt></h3>
<p>Registers the script engine called <i>name</i> and returns true if the engine was found; otherwise does nothing and returns false.</p>
<p>The script engine will be used when loading files with the given <i>extension</i>, or when loading source code that contains the string <i>code</i>.</p>
<!-- @@@registerEngine -->
<!-- $$$script[overload1]$$$scriptconstQString& -->
<h3 class="fn"><a name="script"></a><span class="type"><a href="qaxscript.html">QAxScript</a></span> * QAxScriptManager::<span class="name">script</span> ( const <span class="type"><a href="qstring.html">QString</a></span> & <i>name</i> ) const</h3>
<p>Returns the script called <i>name</i>.</p>
<p>You can use the returned pointer to call functions directly through <a href="qaxscript.html#call">QAxScript::call</a>(), to access the script engine directly, or to delete and thus unload the script.</p>
<!-- @@@script -->
<!-- $$$scriptFileFilter[overload1]$$$scriptFileFilter -->
<h3 class="fn"><a name="scriptFileFilter"></a><span class="type"><a href="qstring.html">QString</a></span> QAxScriptManager::<span class="name">scriptFileFilter</span> ()<tt> [static]</tt></h3>
<p>Returns a file filter listing all the supported script languages. This filter string is convenient for use with <a href="qfiledialog.html">QFileDialog</a>.</p>
<!-- @@@scriptFileFilter -->
<!-- $$$scriptNames[overload1]$$$scriptNames -->
<h3 class="fn"><a name="scriptNames"></a><span class="type"><a href="qstringlist.html">QStringList</a></span> QAxScriptManager::<span class="name">scriptNames</span> () const</h3>
<p>Returns a list with the names of all the scripts.</p>
<!-- @@@scriptNames -->
</div>
<div class="ft">
<span></span>
</div>
</div>
<div class="footer">
<p>
<acronym title="Copyright">©</acronym> 2012 Nokia Corporation and/or its
subsidiaries. Documentation contributions included herein are the copyrights of
their respective owners.</p>
<br />
<p>
The documentation provided herein is licensed under the terms of the
<a href="http://www.gnu.org/licenses/fdl.html">GNU Free Documentation
License version 1.3</a> as published by the Free Software Foundation.</p>
<p>
Documentation sources may be obtained from <a href="http://www.qt-project.org">
www.qt-project.org</a>.</p>
<br />
<p>
Nokia, Qt and their respective logos are trademarks of Nokia Corporation
in Finland and/or other countries worldwide. All other trademarks are property
of their respective owners. <a title="Privacy Policy"
href="http://en.gitorious.org/privacy_policy/">Privacy Policy</a></p>
</div>
</body>
</html>
|