~oif-team/ubuntu/natty/qt4-x11/xi2.1

« back to all changes in this revision

Viewing changes to doc/html/qpluginloader.html

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-08-24 04:09:09 UTC
  • Revision ID: james.westby@ubuntu.com-20050824040909-xmxe9jfr4a0w5671
Tags: upstream-4.0.0
ImportĀ upstreamĀ versionĀ 4.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?xml version="1.0" encoding="iso-8859-1"?>
 
2
<!DOCTYPE html
 
3
    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
 
4
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
 
5
<!-- /tmp/qt-4.0.0-espenr-1119621036935/qt-x11-opensource-desktop-4.0.0/src/corelib/plugin/qpluginloader.cpp -->
 
6
<head>
 
7
    <title>Qt 4.0: QPluginLoader Class Reference</title>
 
8
    <style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm; }
 
9
a:link { color: #004faf; text-decoration: none }
 
10
a:visited { color: #672967; text-decoration: none }
 
11
td.postheader { font-family: sans-serif }
 
12
tr.address { font-family: sans-serif }
 
13
body { background: #ffffff; color: black; }</style>
 
14
</head>
 
15
<body>
 
16
<table border="0" cellpadding="0" cellspacing="0" width="100%">
 
17
<tr>
 
18
<td align="left" valign="top" width="32"><img src="images/qt-logo.png" align="left" width="32" height="32" border="0" /></td>
 
19
<td width="1">&nbsp;&nbsp;</td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a>&nbsp;&middot; <a href="classes.html"><font color="#004faf">All&nbsp;Classes</font></a>&nbsp;&middot; <a href="mainclasses.html"><font color="#004faf">Main&nbsp;Classes</font></a>&nbsp;&middot; <a href="annotated.html"><font color="#004faf">Annotated</font></a>&nbsp;&middot; <a href="groups.html"><font color="#004faf">Grouped&nbsp;Classes</font></a>&nbsp;&middot; <a href="functions.html"><font color="#004faf">Functions</font></a></td>
 
20
<td align="right" valign="top" width="230"><img src="images/trolltech-logo.png" align="right" width="203" height="32" border="0" /></td></tr></table><h1 align="center">QPluginLoader Class Reference</h1>
 
21
<p>The QPluginLoader class loads a plugin at run-time. <a href="#details">More...</a></p>
 
22
<pre>#include &lt;QPluginLoader&gt;</pre><p>Part of the <a href="qtcore.html">QtCore</a> module.</p>
 
23
<p>Inherits <a href="qobject.html">QObject</a>.</p>
 
24
<p><b>Note:</b> All the functions in this class are <a href="threads.html#reentrant">reentrant</a>.</p>
 
25
<ul>
 
26
<li><a href="qpluginloader-members.html">List of all members, including inherited members</a></li>
 
27
</ul>
 
28
<a name="properties"></a>
 
29
<h3>Properties</h3>
 
30
<ul>
 
31
<li><div class="fn"/><b><a href="qpluginloader.html#fileName-prop">fileName</a></b> : QString</li>
 
32
</ul>
 
33
<ul>
 
34
<li><div class="fn"/>1 property inherited from <a href="qobject.html#properties">QObject</a></li>
 
35
</ul>
 
36
<a name="public-functions"></a>
 
37
<h3>Public Functions</h3>
 
38
<ul>
 
39
<li><div class="fn"/><b><a href="qpluginloader.html#QPluginLoader">QPluginLoader</a></b> ( QObject * <i>parent</i> = 0 )</li>
 
40
<li><div class="fn"/><b><a href="qpluginloader.html#QPluginLoader-2">QPluginLoader</a></b> ( const QString &amp; <i>fileName</i>, QObject * <i>parent</i> = 0 )</li>
 
41
<li><div class="fn"/><b><a href="qpluginloader.html#dtor.QPluginLoader">~QPluginLoader</a></b> ()</li>
 
42
<li><div class="fn"/>QString <b><a href="qpluginloader.html#fileName-prop">fileName</a></b> () const</li>
 
43
<li><div class="fn"/>QObject * <b><a href="qpluginloader.html#instance">instance</a></b> ()</li>
 
44
<li><div class="fn"/>bool <b><a href="qpluginloader.html#isLoaded">isLoaded</a></b> () const</li>
 
45
<li><div class="fn"/>bool <b><a href="qpluginloader.html#load">load</a></b> ()</li>
 
46
<li><div class="fn"/>void <b><a href="qpluginloader.html#fileName-prop">setFileName</a></b> ( const QString &amp; <i>fileName</i> )</li>
 
47
<li><div class="fn"/>bool <b><a href="qpluginloader.html#unload">unload</a></b> ()</li>
 
48
</ul>
 
49
<ul>
 
50
<li><div class="fn"/>28 public functions inherited from <a href="qobject.html#public-functions">QObject</a></li>
 
51
</ul>
 
52
<a name="static-public-members"></a>
 
53
<h3>Static Public Members</h3>
 
54
<ul>
 
55
<li><div class="fn"/>QObjectList <b><a href="qpluginloader.html#staticInstances">staticInstances</a></b> ()</li>
 
56
</ul>
 
57
<ul>
 
58
<li><div class="fn"/>4 static public members inherited from <a href="qobject.html#static-public-members">QObject</a></li>
 
59
</ul>
 
60
<a name="macros"></a>
 
61
<h3>Macros</h3>
 
62
<ul>
 
63
<li><div class="fn"/><b><a href="qpluginloader.html#Q_DECLARE_INTERFACE">Q_DECLARE_INTERFACE</a></b> (  <i>ClassName</i>,  <i>Identifier</i> )</li>
 
64
<li><div class="fn"/><b><a href="qpluginloader.html#Q_EXPORT_PLUGIN">Q_EXPORT_PLUGIN</a></b> (  <i>ClassName</i> )</li>
 
65
</ul>
 
66
<h3>Additional Inherited Members</h3>
 
67
<ul>
 
68
<li><div class="fn"/>1 public slot inherited from <a href="qobject.html#public-slots">QObject</a></li>
 
69
<li><div class="fn"/>1 signal inherited from <a href="qobject.html#signals">QObject</a></li>
 
70
<li><div class="fn"/>7 protected functions inherited from <a href="qobject.html#protected-functions">QObject</a></li>
 
71
</ul>
 
72
<a name="details"></a>
 
73
<hr />
 
74
<h2>Detailed Description</h2>
 
75
<p>The QPluginLoader class loads a plugin at run-time.</p>
 
76
<p>QPlugingLoader provides a means for accessing a <a href="plugins-howto.html">Qt plugin</a>. Qt plugins are stored in a shared library (a &quot;DLL&quot;) and follow offer a few benefits over plain shared libraries accessed using <a href="qlibrary.html">QLibrary</a>:</p>
 
77
<ul>
 
78
<li>Plugins offer safety in cases where a plugin is linked against different versions of Qt. (This typically would result in the application crashing when opening such a library with <a href="qlibrary.html">QLibrary</a>.)</li>
 
79
<li>Plugin offers direct access to a root component object (<a href="qpluginloader.html#instance">instance</a>()), instead of forcing you to resolve a C function manually.</li>
 
80
</ul>
 
81
<p>An instance of a QPluginLoader object operates on a single shared library file, which we call a plugin. It provides access to the functionality in the plugin in a platform-independent way. To specify which plugin to load, you can either pass a file name in the constructor or set it with <a href="qpluginloader.html#fileName-prop">setFileName</a>().</p>
 
82
<p>The most important functions are <a href="qpluginloader.html#load">load</a>() to dynamically load the plugin file, <a href="qpluginloader.html#isLoaded">isLoaded</a>() to check whether loading was successful, and <a href="qpluginloader.html#instance">instance</a>() to access the root component in the plugin. The <a href="qpluginloader.html#instance">instance</a>() function implicitly tries to load the plugin if it has not been loaded yet. Multiple instances of QPluginLoader can be used to access the same physical plugin.</p>
 
83
<p>Once loaded, plugins remain in memory until the application terminates. You can attempt to unload a plugin using <a href="qpluginloader.html#unload">unload</a>(), but if other instances of QPluginLoader are using the same library, the call will fail, and unloading will only happen when every instance has called <a href="qpluginloader.html#unload">unload</a>().</p>
 
84
<p>See <a href="plugins-howto.html">How to Create Qt Plugins</a> for more information about how to make your application extensible through plugins.</p>
 
85
<p>See also <a href="qlibrary.html">QLibrary</a>.</p>
 
86
<hr />
 
87
<h2>Property Documentation</h2>
 
88
<h3 class="fn"><a name="fileName-prop"></a>fileName : <a href="qstring.html">QString</a></h3>
 
89
<p>This property holds the file name of the plugin.</p>
 
90
<p>To be loadable, the file's suffix must be a valid suffix for a loadable library in accordance with the platform, e.g. <tt>.so</tt> on Unix, - <tt>.dylib</tt> on Mac OS X, and <tt>.dll</tt> on Windows. The suffix can be verified with <a href="qlibrary.html#isLibrary">QLibrary::isLibrary</a>().</p>
 
91
<p>Access functions:</p>
 
92
<ul>
 
93
<li><div class="fn"/><b>QString fileName () const</b></li>
 
94
<li><div class="fn"/><b>void setFileName ( const QString &amp; <i>fileName</i> )</b></li>
 
95
</ul>
 
96
<p>See also <a href="qpluginloader.html#load">load</a>().</p>
 
97
<hr />
 
98
<h2>Member Function Documentation</h2>
 
99
<h3 class="fn"><a name="QPluginLoader"></a>QPluginLoader::QPluginLoader ( <a href="qobject.html">QObject</a> * <i>parent</i> = 0 )</h3>
 
100
<p>Constructs a plugin loader with the given <i>parent</i>.</p>
 
101
<h3 class="fn"><a name="QPluginLoader-2"></a>QPluginLoader::QPluginLoader ( const <a href="qstring.html">QString</a> &amp; <i>fileName</i>, <a href="qobject.html">QObject</a> * <i>parent</i> = 0 )</h3>
 
102
<p>Constructs a plugin loader with the given <i>parent</i> that will load the plugin specified by <i>fileName</i>.</p>
 
103
<p>To be loadable, the file's suffix must be a valid suffix for a loadable library in accordance with the platform, e.g. <tt>.so</tt> on Unix, - <tt>.dylib</tt> on Mac OS X, and <tt>.dll</tt> on Windows. The suffix can be verified with <a href="qlibrary.html#isLibrary">QLibrary::isLibrary</a>().</p>
 
104
<p>See also <a href="qpluginloader.html#fileName-prop">setFileName</a>().</p>
 
105
<h3 class="fn"><a name="dtor.QPluginLoader"></a>QPluginLoader::~QPluginLoader ()</h3>
 
106
<p>Destroys the <a href="qpluginloader.html">QPluginLoader</a> object.</p>
 
107
<p>Unless <a href="qpluginloader.html#unload">unload</a>() was called explicitly, the plugin stays in memory until the application terminates.</p>
 
108
<p>See also <a href="qpluginloader.html#isLoaded">isLoaded</a>() and <a href="qpluginloader.html#unload">unload</a>().</p>
 
109
<h3 class="fn"><a name="instance"></a><a href="qobject.html">QObject</a> * QPluginLoader::instance ()</h3>
 
110
<p>Returns the root component object of the plugin. The plugin is loaded if necessary. The function returns 0 if the plugin could not be loaded or if the root component object could not be instantiated.</p>
 
111
<p>If the root component object was destroyed, calling this function creates a new instance.</p>
 
112
<p>The instance is not deleted when the <a href="qpluginloader.html">QPluginLoader</a> is destroyed.</p>
 
113
<p>The component object is a <a href="qobject.html">QObject</a>. Use <a href="qobject.html#qobject_cast">qobject_cast</a>() to access interfaces you are interested in.</p>
 
114
<p>See also <a href="qpluginloader.html#load">load</a>().</p>
 
115
<h3 class="fn"><a name="isLoaded"></a>bool QPluginLoader::isLoaded () const</h3>
 
116
<p>Returns true if the plugin is loaded; otherwise returns false.</p>
 
117
<p>See also <a href="qpluginloader.html#load">load</a>().</p>
 
118
<h3 class="fn"><a name="load"></a>bool QPluginLoader::load ()</h3>
 
119
<p>Loads the plugin and returns true if the plugin was loaded successfully; otherwise returns false. Since <a href="qpluginloader.html#instance">instance</a>() always calls this function before resolving any symbols it is not necessary to call it explicitly. In some situations you might want the plugin loaded in advance, in which case you would use this function.</p>
 
120
<p>On Darwin and Mac OS X this function uses code from dlcompat, part of the OpenDarwin project.</p>
 
121
<pre>&nbsp;   Copyright (c) 2002 Jorge Acereda and Peter O'Gorman.
 
122
 
 
123
    Permission is hereby granted, free of charge, to any person obtaining
 
124
    a copy of this software and associated documentation files (the
 
125
    &quot;Software&quot;), to deal in the Software without restriction, including
 
126
    without limitation the rights to use, copy, modify, merge, publish,
 
127
    distribute, sublicense, and/or sell copies of the Software, and to
 
128
    permit persons to whom the Software is furnished to do so, subject to
 
129
    the following conditions:
 
130
 
 
131
    The above copyright notice and this permission notice shall be
 
132
    included in all copies or substantial portions of the Software.
 
133
 
 
134
    THE SOFTWARE IS PROVIDED &quot;AS IS&quot;, WITHOUT WARRANTY OF ANY KIND,
 
135
    EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
 
136
    MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 
137
    NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
 
138
    LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
 
139
    OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
 
140
    WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.</pre>
 
141
<p>See also <a href="qpluginloader.html#unload">unload</a>().</p>
 
142
<h3 class="fn"><a name="staticInstances"></a>QObjectList QPluginLoader::staticInstances ()&nbsp;&nbsp;<tt> [static]</tt></h3>
 
143
<h3 class="fn"><a name="unload"></a>bool QPluginLoader::unload ()</h3>
 
144
<p>Unloads the plugin and returns true if the plugin could be unloaded; otherwise returns false.</p>
 
145
<p>This happens automatically on application termination, so you shouldn't normally need to call this function.</p>
 
146
<p>If other instances of <a href="qpluginloader.html">QPluginLoader</a> are using the same plugin, the call will fail, and unloading will only happen when every instance has called unload().</p>
 
147
<p>See also <a href="qpluginloader.html#instance">instance</a>() and <a href="qpluginloader.html#load">load</a>().</p>
 
148
<hr />
 
149
<h2>Macro Documentation</h2>
 
150
<h3 class="fn"><a name="Q_DECLARE_INTERFACE"></a>Q_DECLARE_INTERFACE (  <i>ClassName</i>,  <i>Identifier</i> )</h3>
 
151
<p>This macro associates the given <i>Identifier</i> (a string literal) to the interface class called <i>ClassName</i>.</p>
 
152
<p>Example:</p>
 
153
<pre>&nbsp;   Q_DECLARE_INTERFACE(BrushInterface,
 
154
                        &quot;com.trolltech.PlugAndPaint.BrushInterface/1.0&quot;)</pre>
 
155
<p>This macro is normally used right after the class definition for <i>ClassName</i>, in a header file. See the <a href="tools-plugandpaint.html">Plug &amp; Paint</a> example for details.</p>
 
156
<p>See also Q_INTERFACE(), <a href="qpluginloader.html#Q_EXPORT_PLUGIN">Q_EXPORT_PLUGIN</a>(), and <a href="plugins-howto.html">How to Create Qt Plugins</a>.</p>
 
157
<h3 class="fn"><a name="Q_EXPORT_PLUGIN"></a>Q_EXPORT_PLUGIN (  <i>ClassName</i> )</h3>
 
158
<p>This macro exports the plugin class <i>ClassName</i>. There should be exactly one occurrence of this macro in a Qt plugin's source code (in an implementation file).</p>
 
159
<p>Example:</p>
 
160
<pre>&nbsp;   Q_EXPORT_PLUGIN(ExtraFiltersPlugin)</pre>
 
161
<p>See the <a href="tools-plugandpaint.html">Plug &amp; Paint</a> example for details.</p>
 
162
<p>See also <a href="qpluginloader.html#Q_DECLARE_INTERFACE">Q_DECLARE_INTERFACE</a>() and <a href="plugins-howto.html">How to Create Qt Plugins</a>.</p>
 
163
<p /><address><hr /><div align="center">
 
164
<table width="100%" cellspacing="0" border="0"><tr class="address">
 
165
<td width="30%">Copyright &copy; 2005 <a href="trolltech.html">Trolltech</a></td>
 
166
<td width="40%" align="center"><a href="trademarks.html">Trademarks</a></td>
 
167
<td width="30%" align="right"><div align="right">Qt 4.0.0</div></td>
 
168
</tr></table></div></address></body>
 
169
</html>