File: qpluginloader.html

package info (click to toggle)
qt4-x11 4%3A4.8.2%2Bdfsg-11
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 701,696 kB
  • sloc: cpp: 2,686,179; ansic: 375,485; python: 25,859; sh: 19,349; xml: 17,091; perl: 14,765; yacc: 5,383; asm: 5,038; makefile: 1,259; lex: 555; ruby: 526; objc: 347; cs: 112; pascal: 112; php: 54; sed: 34
file content (231 lines) | stat: -rw-r--r-- 19,916 bytes parent folder | download
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
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
<?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" />
<!-- qpluginloader.cpp -->
  <title>Qt 4.8: QPluginLoader 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="qtcore.html">QtCore</a></li>
<li>QPluginLoader</li>
    </ul>
  </div>
</div>
<div class="content mainContent">
<div class="toc">
<h3><a name="toc">Contents</a></h3>
<ul>
<li class="level1"><a href="#properties">Properties</a></li>
<li class="level1"><a href="#public-functions">Public Functions</a></li>
<li class="level1"><a href="#static-public-members">Static Public Members</a></li>
<li class="level1"><a href="#related-non-members">Related Non-Members</a></li>
<li class="level1"><a href="#details">Detailed Description</a></li>
</ul>
</div>
<h1 class="title">QPluginLoader Class Reference</h1>
<!-- $$$QPluginLoader-brief -->
<p>The QPluginLoader class loads a plugin at run-time. <a href="#details">More...</a></p>
<!-- @@@QPluginLoader -->
<pre class="cpp"> <span class="preprocessor">#include &lt;QPluginLoader&gt;</span></pre><p><b>Inherits: </b><a href="qobject.html">QObject</a>.</p>
<p><b>Note:</b> All functions in this class are <a href="threads-reentrancy.html#reentrant">reentrant</a>.</p>
<ul>
<li><a href="qpluginloader-members.html">List of all members, including inherited members</a></li>
</ul>
<a name="properties"></a>
<h2>Properties</h2>
<ul>
<li class="fn"><b><a href="qpluginloader.html#fileName-prop">fileName</a></b> : QString</li>
<li class="fn"><b><a href="qpluginloader.html#loadHints-prop">loadHints</a></b> : QLibrary::LoadHints</li>
</ul>
<ul>
<li class="fn">1 property inherited from <a href="qobject.html#properties">QObject</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="qpluginloader.html#QPluginLoader">QPluginLoader</a></b> ( QObject * <i>parent</i> = 0 )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qpluginloader.html#QPluginLoader-2">QPluginLoader</a></b> ( const QString &amp; <i>fileName</i>, QObject * <i>parent</i> = 0 )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qpluginloader.html#dtor.QPluginLoader">~QPluginLoader</a></b> ()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QString </td><td class="memItemRight bottomAlign"><b><a href="qpluginloader.html#errorString">errorString</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QString </td><td class="memItemRight bottomAlign"><b><a href="qpluginloader.html#fileName-prop">fileName</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QObject * </td><td class="memItemRight bottomAlign"><b><a href="qpluginloader.html#instance">instance</a></b> ()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qpluginloader.html#isLoaded">isLoaded</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qpluginloader.html#load">load</a></b> ()</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QLibrary::LoadHints </td><td class="memItemRight bottomAlign"><b><a href="qpluginloader.html#loadHints-prop">loadHints</a></b> () const</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qpluginloader.html#fileName-prop">setFileName</a></b> ( const QString &amp; <i>fileName</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qpluginloader.html#loadHints-prop">setLoadHints</a></b> ( QLibrary::LoadHints <i>loadHints</i> )</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> bool </td><td class="memItemRight bottomAlign"><b><a href="qpluginloader.html#unload">unload</a></b> ()</td></tr>
</table>
<ul>
<li class="fn">29 public functions inherited from <a href="qobject.html#public-functions">QObject</a></li>
</ul>
<a name="static-public-members"></a>
<h2>Static Public Members</h2>
<table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> QObjectList </td><td class="memItemRight bottomAlign"><b><a href="qpluginloader.html#staticInstances">staticInstances</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>
<a name="related-non-members"></a>
<h2>Related Non-Members</h2>
<table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qpluginloader.html#qRegisterStaticPluginInstanceFunction">qRegisterStaticPluginInstanceFunction</a></b> ( QtPluginInstanceFunction <i>function</i> )</td></tr>
</table>
<h3>Additional Inherited Members</h3>
<ul>
<li class="fn">1 public slot inherited from <a href="qobject.html#public-slots">QObject</a></li>
<li class="fn">1 signal inherited from <a href="qobject.html#signals">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>
<!-- $$$QPluginLoader-description -->
<div class="descr">
<h2>Detailed Description</h2>
<p>The QPluginLoader class loads a plugin at run-time.</p>
<p>QPluginLoader provides access to a <a href="plugins-howto.html">Qt plugin</a>. A Qt plugin is stored in a shared library (a DLL) and offers these benefits over shared libraries accessed using <a href="qlibrary.html">QLibrary</a>:</p>
<ul>
<li>QPluginLoader checks that a plugin is linked against the same version of Qt as the application.</li>
<li>QPluginLoader provides 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>
</ul>
<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, either pass a file name in the constructor or set it with <a href="qpluginloader.html#fileName-prop">setFileName</a>().</p>
<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>
<p>Once loaded, plugins remain in memory until all instances of QPluginLoader has been unloaded, or 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>(). Right before the unloading happen, the root component will also be deleted.</p>
<p>In order to speed up loading and validation of plugins, some of the information that is collected during loading is cached in persistent memory (through <a href="qsettings.html">QSettings</a>). For instance, the result of a load operation (e.g&#x2e; succeeded or failed) is stored in the cache, so that subsequent load operations don't try to load an invalid plugin. However, if the &quot;last modified&quot; timestamp of a plugin has changed, the plugin's cache entry is invalidated and the plugin is reloaded regardless of the values in the cache entry. The cache entry is then updated with the new result of the load operation.</p>
<p>This also means that the timestamp must be updated each time the plugin or any dependent resources (such as a shared library) is updated, since the dependent resources might influence the result of loading a plugin.</p>
<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>
<p>Note that the QPluginLoader cannot be used if your application is statically linked against Qt. In this case, you will also have to link to plugins statically. You can use <a href="qlibrary.html">QLibrary</a> if you need to load dynamic libraries in a statically linked application.</p>
<p><b>Note:</b> In Symbian the plugin stub files must be used whenever a path to plugin is needed. For the purposes of loading plugins, the stubs can be considered to have the same name as the actual plugin binary. In practice they have &quot;.qtplugin&quot; extension instead of &quot;.dll&quot;, but this difference is handled transparently by QPluginLoader and <a href="qlibrary.html">QLibrary</a> to avoid need for Symbian specific plugin handling in most Qt applications. Plugin stubs are needed because Symbian Platform Security denies all access to the directory where the actual plugin binaries are located.</p>
</div>
<p><b>See also </b><a href="qlibrary.html">QLibrary</a> and <a href="tools-plugandpaint.html">Plug &amp; Paint Example</a>.</p>
<!-- @@@QPluginLoader -->
<div class="prop">
<h2>Property Documentation</h2>
<!-- $$$fileName-prop$$$fileName$$$setFileNameconstQString& -->
<h3 class="fn"><a name="fileName-prop"></a><span class="name">fileName</span> : <span class="type"><a href="qstring.html">QString</a></span></h3>
<p>This property holds the file name of the plugin.</p>
<p>To be loadable, the file's suffix must be a valid suffix for a loadable library in accordance with the platform, e.g&#x2e; <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>
<p>If the file name does not exist, it will not be set. This property will then contain an empty string.</p>
<p>By default, this property contains an empty string.</p>
<p>Note: In Symbian the <i>fileName</i> must point to plugin stub file.</p>
<p><b>Access functions:</b></p>
<table class="alignedsummary">
<tr><td class="memItemLeft topAlign rightAlign"> QString </td><td class="memItemRight bottomAlign"><span class="name"><b>fileName</b></span> () const</td></tr>
<tr><td class="memItemLeft topAlign rightAlign"> void </td><td class="memItemRight bottomAlign"><span class="name"><b>setFileName</b></span> ( const QString &amp; <i>fileName</i> )</td></tr>
</table>
<p><b>See also </b><a href="qpluginloader.html#load">load</a>().</p>
<!-- @@@fileName -->
<!-- $$$loadHints-prop$$$loadHints$$$setLoadHintsQLibrary::LoadHints -->
<h3 class="fn"><a name="loadHints-prop"></a><span class="name">loadHints</span> : <span class="type"><a href="qlibrary.html#LoadHint-enum">QLibrary::LoadHints</a></span></h3>
<p>This property holds give the load() function some hints on how it should behave.</p>
<p>You can give hints on how the symbols in the plugin are resolved. By default, none of the hints are set.</p>
<p>See the documentation of <a href="qlibrary.html#loadHints-prop">QLibrary::loadHints</a> for a complete description of how this property works.</p>
<p>This property was introduced in Qt 4.4.</p>
<p><b>Access functions:</b></p>
<table class="alignedsummary">
<tr><td class="memItemLeft topAlign rightAlign"> QLibrary::LoadHints </td><td class="memItemRight bottomAlign"><span class="name"><b>loadHints</b></span> () const</td></tr>
<tr><td class="memItemLeft topAlign rightAlign"> void </td><td class="memItemRight bottomAlign"><span class="name"><b>setLoadHints</b></span> ( QLibrary::LoadHints <i>loadHints</i> )</td></tr>
</table>
<p><b>See also </b><a href="qlibrary.html#loadHints-prop">QLibrary::loadHints</a>.</p>
<!-- @@@loadHints -->
</div>
<div class="func">
<h2>Member Function Documentation</h2>
<!-- $$$QPluginLoader[overload1]$$$QPluginLoaderQObject* -->
<h3 class="fn"><a name="QPluginLoader"></a>QPluginLoader::<span class="name">QPluginLoader</span> ( <span class="type"><a href="qobject.html">QObject</a></span> * <i>parent</i> = 0 )</h3>
<p>Constructs a plugin loader with the given <i>parent</i>.</p>
<!-- @@@QPluginLoader -->
<!-- $$$QPluginLoader$$$QPluginLoaderconstQString&QObject* -->
<h3 class="fn"><a name="QPluginLoader-2"></a>QPluginLoader::<span class="name">QPluginLoader</span> ( const <span class="type"><a href="qstring.html">QString</a></span> &amp; <i>fileName</i>, <span class="type"><a href="qobject.html">QObject</a></span> * <i>parent</i> = 0 )</h3>
<p>Constructs a plugin loader with the given <i>parent</i> that will load the plugin specified by <i>fileName</i>.</p>
<p>To be loadable, the file's suffix must be a valid suffix for a loadable library in accordance with the platform, e.g&#x2e; <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>
<p>Note: In Symbian the <i>fileName</i> must point to plugin stub file.</p>
<p><b>See also </b><a href="qpluginloader.html#fileName-prop">setFileName</a>().</p>
<!-- @@@QPluginLoader -->
<!-- $$$~QPluginLoader[overload1]$$$~QPluginLoader -->
<h3 class="fn"><a name="dtor.QPluginLoader"></a>QPluginLoader::<span class="name">~QPluginLoader</span> ()</h3>
<p>Destroys the <a href="qpluginloader.html">QPluginLoader</a> object.</p>
<p>Unless <a href="qpluginloader.html#unload">unload</a>() was called explicitly, the plugin stays in memory until the application terminates.</p>
<p><b>See also </b><a href="qpluginloader.html#isLoaded">isLoaded</a>() and <a href="qpluginloader.html#unload">unload</a>().</p>
<!-- @@@~QPluginLoader -->
<!-- $$$errorString[overload1]$$$errorString -->
<h3 class="fn"><a name="errorString"></a><span class="type"><a href="qstring.html">QString</a></span> QPluginLoader::<span class="name">errorString</span> () const</h3>
<p>Returns a text string with the description of the last error that occurred.</p>
<p>This function was introduced in Qt 4.2.</p>
<!-- @@@errorString -->
<!-- $$$instance[overload1]$$$instance -->
<h3 class="fn"><a name="instance"></a><span class="type"><a href="qobject.html">QObject</a></span> * QPluginLoader::<span class="name">instance</span> ()</h3>
<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>
<p>If the root component object was destroyed, calling this function creates a new instance.</p>
<p>The root component, returned by this function, is not deleted when the <a href="qpluginloader.html">QPluginLoader</a> is destroyed. If you want to ensure that the root component is deleted, you should call <a href="qpluginloader.html#unload">unload</a>() as soon you don't need to access the core component anymore. When the library is finally unloaded, the root component will automatically be deleted.</p>
<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>
<p><b>See also </b><a href="qpluginloader.html#load">load</a>().</p>
<!-- @@@instance -->
<!-- $$$isLoaded[overload1]$$$isLoaded -->
<h3 class="fn"><a name="isLoaded"></a><span class="type">bool</span> QPluginLoader::<span class="name">isLoaded</span> () const</h3>
<p>Returns true if the plugin is loaded; otherwise returns false.</p>
<p><b>See also </b><a href="qpluginloader.html#load">load</a>().</p>
<!-- @@@isLoaded -->
<!-- $$$load[overload1]$$$load -->
<h3 class="fn"><a name="load"></a><span class="type">bool</span> QPluginLoader::<span class="name">load</span> ()</h3>
<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>
<p><b>See also </b><a href="qpluginloader.html#unload">unload</a>().</p>
<!-- @@@load -->
<!-- $$$staticInstances[overload1]$$$staticInstances -->
<h3 class="fn"><a name="staticInstances"></a><span class="type"><a href="qobject.html#QObjectList-typedef">QObjectList</a></span> QPluginLoader::<span class="name">staticInstances</span> ()<tt> [static]</tt></h3>
<p>Returns a list of static plugin instances (root components) held by the plugin loader.</p>
<!-- @@@staticInstances -->
<!-- $$$unload[overload1]$$$unload -->
<h3 class="fn"><a name="unload"></a><span class="type">bool</span> QPluginLoader::<span class="name">unload</span> ()</h3>
<p>Unloads the plugin and returns true if the plugin could be unloaded; otherwise returns false.</p>
<p>This happens automatically on application termination, so you shouldn't normally need to call this function.</p>
<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>
<p>Don't try to delete the root component. Instead rely on that unload() will automatically delete it when needed.</p>
<p><b>See also </b><a href="qpluginloader.html#instance">instance</a>() and <a href="qpluginloader.html#load">load</a>().</p>
<!-- @@@unload -->
</div>
<div class="relnonmem">
<h2>Related Non-Members</h2>
<!-- $$$qRegisterStaticPluginInstanceFunction[overload1]$$$qRegisterStaticPluginInstanceFunctionQtPluginInstanceFunction -->
<h3 class="fn"><a name="qRegisterStaticPluginInstanceFunction"></a><span class="type">void</span> <span class="name">qRegisterStaticPluginInstanceFunction</span> ( <span class="type">QtPluginInstanceFunction</span> <i>function</i> )</h3>
<p>Registers the given <i>function</i> with the plugin loader.</p>
<p>This function was introduced in Qt 4.4.</p>
<!-- @@@qRegisterStaticPluginInstanceFunction -->
</div>
  <div class="ft">
    <span></span>
  </div>
</div> 
<div class="footer">
    <p>
      <acronym title="Copyright">&copy;</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>