Sophie

Sophie

distrib > Mageia > 4 > i586 > by-pkgid > 28b9e36e96ce34b2567ae5b47a27b2c5 > files > 829

python-qt4-doc-4.10.3-3.mga4.noarch.rpm

<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
<html><head><title>QLibrary Class Reference</title><style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }
td.postheader { font-family: sans-serif }
tr.address { font-family: sans-serif }
body { background: #ffffff; color: black; }
</style></head><body><table border="0" cellpadding="0" cellspacing="0" width="100%"><tr /><td align="left" valign="top" width="32"><img align="left" border="0" height="32" src="images/rb-logo.png" width="32" /></td><td width="1">&#160;&#160;</td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a>&#160;&#183; <a href="classes.html"><font color="#004faf">All Classes</font></a>&#160;&#183; <a href="modules.html"><font color="#004faf">Modules</font></a></td></table><h1 align="center">QLibrary Class Reference<br /><sup><sup>[<a href="qtcore.html">QtCore</a> module]</sup></sup></h1><p>The QLibrary class loads shared libraries at runtime. <a href="#details">More...</a></p>

<p>Inherits <a href="qobject.html">QObject</a>.</p><h3>Types</h3><ul><li><div class="fn" />enum <b><a href="qlibrary.html#LoadHint-enum">LoadHint</a></b> { ResolveAllSymbolsHint, ExportExternalSymbolsHint, LoadArchiveMemberHint }</li><li><div class="fn" />class <b><a href="qlibrary-loadhints.html">LoadHints</a></b></li></ul><h3>Methods</h3><ul><li><div class="fn" /><b><a href="qlibrary.html#QLibrary">__init__</a></b> (<i>self</i>, QObject&#160;<i>parent</i>&#160;=&#160;None)</li><li><div class="fn" /><b><a href="qlibrary.html#QLibrary-2">__init__</a></b> (<i>self</i>, QString&#160;<i>fileName</i>, QObject&#160;<i>parent</i>&#160;=&#160;None)</li><li><div class="fn" /><b><a href="qlibrary.html#QLibrary-3">__init__</a></b> (<i>self</i>, QString&#160;<i>fileName</i>, int&#160;<i>verNum</i>, QObject&#160;<i>parent</i>&#160;=&#160;None)</li><li><div class="fn" /><b><a href="qlibrary.html#QLibrary-4">__init__</a></b> (<i>self</i>, QString&#160;<i>fileName</i>, QString&#160;<i>version</i>, QObject&#160;<i>parent</i>&#160;=&#160;None)</li><li><div class="fn" />QString <b><a href="qlibrary.html#errorString">errorString</a></b> (<i>self</i>)</li><li><div class="fn" />QString <b><a href="qlibrary.html#fileName">fileName</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qlibrary.html#isLoaded">isLoaded</a></b> (<i>self</i>)</li><li><div class="fn" />bool <b><a href="qlibrary.html#load">load</a></b> (<i>self</i>)</li><li><div class="fn" />LoadHints <b><a href="qlibrary.html#loadHints">loadHints</a></b> (<i>self</i>)</li><li><div class="fn" />sip.voidptr <b><a href="qlibrary.html#resolve">resolve</a></b> (<i>self</i>, str&#160;<i>symbol</i>)</li><li><div class="fn" /><b><a href="qlibrary.html#setFileName">setFileName</a></b> (<i>self</i>, QString&#160;<i>fileName</i>)</li><li><div class="fn" /><b><a href="qlibrary.html#setFileNameAndVersion">setFileNameAndVersion</a></b> (<i>self</i>, QString&#160;<i>fileName</i>, int&#160;<i>verNum</i>)</li><li><div class="fn" /><b><a href="qlibrary.html#setFileNameAndVersion-2">setFileNameAndVersion</a></b> (<i>self</i>, QString&#160;<i>fileName</i>, QString&#160;<i>version</i>)</li><li><div class="fn" /><b><a href="qlibrary.html#setLoadHints">setLoadHints</a></b> (<i>self</i>, LoadHints&#160;<i>hints</i>)</li><li><div class="fn" />bool <b><a href="qlibrary.html#unload">unload</a></b> (<i>self</i>)</li></ul><h3>Static Methods</h3><ul><li><div class="fn" />bool <b><a href="qlibrary.html#isLibrary">isLibrary</a></b> (QString&#160;<i>fileName</i>)</li><li><div class="fn" />sip.voidptr <b><a href="qlibrary.html#resolve-2">resolve</a></b> (QString&#160;<i>fileName</i>, str&#160;<i>symbol</i>)</li><li><div class="fn" />sip.voidptr <b><a href="qlibrary.html#resolve-3">resolve</a></b> (QString&#160;<i>fileName</i>, int&#160;<i>verNum</i>, str&#160;<i>symbol</i>)</li><li><div class="fn" />sip.voidptr <b><a href="qlibrary.html#resolve-4">resolve</a></b> (QString&#160;<i>fileName</i>, QString&#160;<i>version</i>, str&#160;<i>symbol</i>)</li></ul><a name="details" /><hr /><h2>Detailed Description</h2><p>The QLibrary class loads shared libraries at runtime.</p>
<p>An instance of a QLibrary object operates on a single shared
object file (which we call a "library", but is also known as a
"DLL"). A QLibrary provides access to the functionality in the
library in a platform independent way. You can either pass a file
name in the constructor, or set it explicitly with <a href="qlibrary.html#fileName-prop">setFileName</a>(). When loading the
library, QLibrary searches in all the system-specific library
locations (e.g. <tt>LD_LIBRARY_PATH</tt> on Unix), unless the file
name has an absolute path. If the file cannot be found, QLibrary
tries the name with different platform-specific file suffixes, like
".so" on Unix, ".dylib" on the Mac, or ".dll" on Windows and
Symbian. This makes it possible to specify shared libraries that
are only identified by their basename (i.e. without their suffix),
so the same code will work on different operating systems.</p>
<p>The most important functions are <a href="qlibrary.html#load">load</a>() to dynamically load the library
file, <a href="qlibrary.html#isLoaded">isLoaded</a>() to check
whether loading was successful, and <a href="qlibrary.html#resolve">resolve</a>() to resolve a symbol in the
library. The <a href="qlibrary.html#resolve">resolve</a>() function
implicitly tries to load the library if it has not been loaded yet.
Multiple instances of QLibrary can be used to access the same
physical library. Once loaded, libraries remain in memory until the
application terminates. You can attempt to unload a library using
<a href="qlibrary.html#unload">unload</a>(), but if other instances
of QLibrary are using the same library, the call will fail, and
unloading will only happen when every instance has called <a href="qlibrary.html#unload">unload</a>().</p>
<p>A typical use of QLibrary is to resolve an exported symbol in a
library, and to call the C function that this symbol represents.
This is called "explicit linking" in contrast to "implicit
linking", which is done by the link step in the build process when
linking an executable against a library.</p>
<p>Note: In Symbian resolving symbols using their names is
supported only if the library is built as STDDLL. Otherwise
ordinals must be used. Also, in Symbian the path of the library is
ignored and system default library location is always used.</p>
<p>The following code snippet loads a library, resolves the symbol
"mysymbol", and calls the function if everything succeeded. If
something goes wrong, e.g. the library file does not exist or the
symbol is not defined, the function pointer will be 0 and won't be
called.</p>
<pre class="cpp">
 <span class="type">QLibrary</span> myLib(<span class="string">"mylib"</span>);
 <span class="keyword">typedef</span> <span class="type">void</span> (<span class="operator">*</span>MyPrototype)();
 MyPrototype myFunction <span class="operator">=</span> (MyPrototype) myLib<span class="operator">.</span><a href="qlibrary.html#resolve">resolve</a>(<span class="string">"mysymbol"</span>);
 <span class="keyword">if</span> (myFunction)
     myFunction();
</pre>
<p>The symbol must be exported as a C function from the library for
<a href="qlibrary.html#resolve">resolve</a>() to work. This means
that the function must be wrapped in an <tt>extern "C"</tt> block
if the library is compiled with a C++ compiler. On Windows, this
also requires the use of a <tt>dllexport</tt> macro; see <a href="qlibrary.html#resolve">resolve</a>() for the details of how this
is done. For convenience, there is a static <a href="qlibrary.html#resolve">resolve</a>() function which you can use if
you just want to call a function in a library without explicitly
loading the library first:</p>
<pre class="cpp">
 <span class="keyword">typedef</span> <span class="type">void</span> (<span class="operator">*</span>MyPrototype)();
 MyPrototype myFunction <span class="operator">=</span>
         (MyPrototype) <span class="type">QLibrary</span><span class="operator">.</span><a href="qlibrary.html#resolve">resolve</a>(<span class="string">"mylib"</span><span class="operator">,</span> <span class="string">"mysymbol"</span>);
 <span class="keyword">if</span> (myFunction)
     myFunction();
</pre><hr /><h2>Type Documentation</h2><h3 class="fn"><a name="LoadHint-enum" />QLibrary.LoadHint</h3><p>This enum describes the possible hints that can be used to
change the way libraries are handled when they are loaded. These
values indicate how symbols are resolved when libraries are loaded,
and are specified using the <a href="qlibrary.html#loadHints-prop">setLoadHints</a>() function.</p>
<table class="valuelist">
<tr class="odd" valign="top">
<th class="tblConst">Constant</th>
<th class="tblval">Value</th>
<th class="tbldscr">Description</th>
</tr>
<tr>
<td class="topAlign"><tt>QLibrary.ResolveAllSymbolsHint</tt></td>
<td class="topAlign"><tt>0x01</tt></td>
<td class="topAlign">Causes all symbols in a library to be resolved
when it is loaded, not simply when <a href="qlibrary.html#resolve">resolve</a>() is called.</td>
</tr>
<tr>
<td class="topAlign">
<tt>QLibrary.ExportExternalSymbolsHint</tt></td>
<td class="topAlign"><tt>0x02</tt></td>
<td class="topAlign">Exports unresolved and external symbols in the
library so that they can be resolved in other dynamically-loaded
libraries loaded later.</td>
</tr>
<tr>
<td class="topAlign"><tt>QLibrary.LoadArchiveMemberHint</tt></td>
<td class="topAlign"><tt>0x04</tt></td>
<td class="topAlign">Allows the file name of the library to specify
a particular object file within an archive file. If this hint is
given, the filename of the library consists of a path, which is a
reference to an archive file, followed by a reference to the
archive member.</td>
</tr>
</table>
<p>The LoadHints type is a typedef for <a href="qflags.html">QFlags</a>&lt;LoadHint&gt;. It stores an OR
combination of LoadHint values.</p>
<p><b>See also</b> <a href="qlibrary.html#loadHints-prop">loadHints</a>.</p>
<hr /><h2>Method Documentation</h2><h3 class="fn"><a name="QLibrary" />QLibrary.__init__ (<i>self</i>, <a href="qobject.html">QObject</a>&#160;<i>parent</i>&#160;=&#160;None)</h3><p>The <i>parent</i> argument, if not None, causes <i>self</i> to be owned by Qt instead of PyQt.</p><p>Constructs a library with the given <i>parent</i>.</p>


<h3 class="fn"><a name="QLibrary-2" />QLibrary.__init__ (<i>self</i>, QString&#160;<i>fileName</i>, <a href="qobject.html">QObject</a>&#160;<i>parent</i>&#160;=&#160;None)</h3><p>The <i>parent</i> argument, if not None, causes <i>self</i> to be owned by Qt instead of PyQt.</p><p>Constructs a library object with the given <i>parent</i> that
will load the library specified by <i>fileName</i>.</p>
<p>We recommend omitting the file's suffix in <i>fileName</i>,
since <a href="qlibrary.html">QLibrary</a> will automatically look
for the file with the appropriate suffix in accordance with the
platform, e.g. ".so" on Unix, ".dylib" on Mac OS X, and ".dll" on
Windows. (See <a href="qlibrary.html#fileName-prop">fileName</a>.)</p>
<p>Note: In Symbian the path portion of the <i>fileName</i> is
ignored.</p>


<h3 class="fn"><a name="QLibrary-3" />QLibrary.__init__ (<i>self</i>, QString&#160;<i>fileName</i>, int&#160;<i>verNum</i>, <a href="qobject.html">QObject</a>&#160;<i>parent</i>&#160;=&#160;None)</h3><p>The <i>parent</i> argument, if not None, causes <i>self</i> to be owned by Qt instead of PyQt.</p><p>Constructs a library object with the given <i>parent</i> that
will load the library specified by <i>fileName</i> and major
version number <i>verNum</i>. Currently, the version number is
ignored on Windows and Symbian.</p>
<p>We recommend omitting the file's suffix in <i>fileName</i>,
since <a href="qlibrary.html">QLibrary</a> will automatically look
for the file with the appropriate suffix in accordance with the
platform, e.g. ".so" on Unix, ".dylib" on Mac OS X, and ".dll" on
Windows. (See <a href="qlibrary.html#fileName-prop">fileName</a>.)</p>
<p>Note: In Symbian the path portion of the <i>fileName</i> is
ignored.</p>


<h3 class="fn"><a name="QLibrary-4" />QLibrary.__init__ (<i>self</i>, QString&#160;<i>fileName</i>, QString&#160;<i>version</i>, <a href="qobject.html">QObject</a>&#160;<i>parent</i>&#160;=&#160;None)</h3><p>The <i>parent</i> argument, if not None, causes <i>self</i> to be owned by Qt instead of PyQt.</p><p>Constructs a library object with the given <i>parent</i> that
will load the library specified by <i>fileName</i> and full version
number <i>version</i>. Currently, the version number is ignored on
Windows and Symbian.</p>
<p>We recommend omitting the file's suffix in <i>fileName</i>,
since <a href="qlibrary.html">QLibrary</a> will automatically look
for the file with the appropriate suffix in accordance with the
platform, e.g. ".so" on Unix, ".dylib" on Mac OS X, and ".dll" on
Windows. (See <a href="qlibrary.html#fileName-prop">fileName</a>.)</p>
<p>Note: In Symbian the path portion of the <i>fileName</i> is
ignored.</p>


<h3 class="fn"><a name="errorString" />QString QLibrary.errorString (<i>self</i>)</h3><p>Returns a text string with the description of the last error
that occurred. Currently, errorString will only be set if <a href="qlibrary.html#load">load</a>(), <a href="qlibrary.html#unload">unload</a>() or <a href="qlibrary.html#resolve">resolve</a>() for some reason fails.</p>
<p>This function was introduced in Qt 4.2.</p>


<h3 class="fn"><a name="fileName" />QString QLibrary.fileName (<i>self</i>)</h3><h3 class="fn"><a name="isLibrary" />bool QLibrary.isLibrary (QString&#160;<i>fileName</i>)</h3><p>Returns true if <i>fileName</i> has a valid suffix for a
loadable library; otherwise returns false.</p>
<table class="generic">
<thead>
<tr class="qt-style">
<th>Platform</th>
<th>Valid suffixes</th>
</tr>
</thead>
<tr class="odd" valign="top">
<td>Windows</td>
<td><tt>.dll</tt>, <tt>.DLL</tt></td>
</tr>
<tr class="even" valign="top">
<td>Unix/Linux</td>
<td><tt>.so</tt></td>
</tr>
<tr class="odd" valign="top">
<td>AIX</td>
<td><tt>.a</tt></td>
</tr>
<tr class="even" valign="top">
<td>HP-UX</td>
<td><tt>.sl</tt>, <tt>.so</tt> (HP-UXi)</td>
</tr>
<tr class="odd" valign="top">
<td>Mac OS X</td>
<td><tt>.dylib</tt>, <tt>.bundle</tt>, <tt>.so</tt></td>
</tr>
<tr class="even" valign="top">
<td>Symbian</td>
<td><tt>.dll</tt></td>
</tr>
</table>
<p>Trailing versioning numbers on Unix are ignored.</p>


<h3 class="fn"><a name="isLoaded" />bool QLibrary.isLoaded (<i>self</i>)</h3><p>Returns true if the library is loaded; otherwise returns
false.</p>
<p><b>See also</b> <a href="qlibrary.html#load">load</a>().</p>


<h3 class="fn"><a name="load" />bool QLibrary.load (<i>self</i>)</h3><p>Loads the library and returns true if the library was loaded
successfully; otherwise returns false. Since <a href="qlibrary.html#resolve">resolve</a>() always calls this function
before resolving any symbols it is not necessary to call it
explicitly. In some situations you might want the library loaded in
advance, in which case you would use this function.</p>
<p><b>See also</b> <a href="qlibrary.html#unload">unload</a>().</p>


<h3 class="fn"><a name="loadHints" /><a href="qlibrary-loadhints.html">LoadHints</a> QLibrary.loadHints (<i>self</i>)</h3><h3 class="fn"><a name="resolve" />sip.voidptr QLibrary.resolve (<i>self</i>, str&#160;<i>symbol</i>)</h3><p>Returns the address of the exported symbol <i>symbol</i>. The
library is loaded if necessary. The function returns 0 if the
symbol could not be resolved or if the library could not be
loaded.</p>
<p>Example:</p>
<pre class="cpp">
 <span class="keyword">typedef</span> <span class="type">int</span> (<span class="operator">*</span>AvgFunction)(<span class="type">int</span><span class="operator">,</span> <span class="type">int</span>);

 AvgFunction avg <span class="operator">=</span> (AvgFunction) library<span class="operator">-</span><span class="operator">&gt;</span>resolve(<span class="string">"avg"</span>);
 <span class="keyword">if</span> (avg)
     <span class="keyword">return</span> avg(<span class="number">5</span><span class="operator">,</span> <span class="number">8</span>);
 <span class="keyword">else</span>
     <span class="keyword">return</span> <span class="operator">-</span><span class="number">1</span>;
</pre>
<p>The symbol must be exported as a C function from the library.
This means that the function must be wrapped in an <tt>extern
"C"</tt> if the library is compiled with a C++ compiler. On Windows
you must also explicitly export the function from the DLL using the
<tt>__declspec(dllexport)</tt> compiler directive, for example:</p>
<pre class="cpp">
 <span class="keyword">extern</span> <span class="string">"C"</span> MY_EXPORT <span class="type">int</span> avg(<span class="type">int</span> a<span class="operator">,</span> <span class="type">int</span> b)
 {
     <span class="keyword">return</span> (a <span class="operator">+</span> b) <span class="operator">/</span> <span class="number">2</span>;
 }
</pre>
<p>with <tt>MY_EXPORT</tt> defined as</p>
<pre class="cpp">
 <span class="preprocessor">#ifdef Q_WS_WIN</span>
 <span class="preprocessor">#define MY_EXPORT __declspec(dllexport)</span>
 <span class="preprocessor">#else</span>
 <span class="preprocessor">#define MY_EXPORT</span>
 <span class="preprocessor">#endif</span>
</pre>
<p>Note: In Symbian resolving with symbol names works only if the
loaded library was built as STDDLL. Otherwise, the ordinals must be
used.</p>


<h3 class="fn"><a name="resolve-2" />sip.voidptr QLibrary.resolve (QString&#160;<i>fileName</i>, str&#160;<i>symbol</i>)</h3><p>This is an overloaded function.</p>
<p>Loads the library <i>fileName</i> and returns the address of the
exported symbol <i>symbol</i>. Note that <i>fileName</i> should not
include the platform-specific file suffix; (see <a href="qlibrary.html#fileName-prop">fileName</a>). The library remains
loaded until the application exits.</p>
<p>The function returns 0 if the symbol could not be resolved or if
the library could not be loaded.</p>
<p>Note: In Symbian resolving with symbol names works only if the
loaded library was built as STDDLL. Otherwise, the ordinals must be
used.</p>
<p><b>See also</b> <a href="qlibrary.html#resolve">resolve</a>().</p>


<h3 class="fn"><a name="resolve-3" />sip.voidptr QLibrary.resolve (QString&#160;<i>fileName</i>, int&#160;<i>verNum</i>, str&#160;<i>symbol</i>)</h3><p>This is an overloaded function.</p>
<p>Loads the library <i>fileName</i> with major version number
<i>verNum</i> and returns the address of the exported symbol
<i>symbol</i>. Note that <i>fileName</i> should not include the
platform-specific file suffix; (see <a href="qlibrary.html#fileName-prop">fileName</a>). The library remains
loaded until the application exits. <i>verNum</i> is ignored on
Windows.</p>
<p>The function returns 0 if the symbol could not be resolved or if
the library could not be loaded.</p>
<p>Note: In Symbian resolving with symbol names works only if the
loaded library was built as STDDLL. Otherwise, the ordinals must be
used.</p>
<p><b>See also</b> <a href="qlibrary.html#resolve">resolve</a>().</p>


<h3 class="fn"><a name="resolve-4" />sip.voidptr QLibrary.resolve (QString&#160;<i>fileName</i>, QString&#160;<i>version</i>, str&#160;<i>symbol</i>)</h3><p>This is an overloaded function.</p>
<p>Loads the library <i>fileName</i> with full version number
<i>version</i> and returns the address of the exported symbol
<i>symbol</i>. Note that <i>fileName</i> should not include the
platform-specific file suffix; (see <a href="qlibrary.html#fileName-prop">fileName</a>). The library remains
loaded until the application exits. <i>version</i> is ignored on
Windows.</p>
<p>The function returns 0 if the symbol could not be resolved or if
the library could not be loaded.</p>
<p>Note: In Symbian resolving with symbol names works only if the
loaded library was built as STDDLL. Otherwise, the ordinals must be
used.</p>
<p>This function was introduced in Qt 4.4.</p>
<p><b>See also</b> <a href="qlibrary.html#resolve">resolve</a>().</p>


<h3 class="fn"><a name="setFileName" />QLibrary.setFileName (<i>self</i>, QString&#160;<i>fileName</i>)</h3><h3 class="fn"><a name="setFileNameAndVersion" />QLibrary.setFileNameAndVersion (<i>self</i>, QString&#160;<i>fileName</i>, int&#160;<i>verNum</i>)</h3><p>Sets the <a href="qlibrary.html#fileName-prop">fileName</a>
property and major version number to <i>fileName</i> and
<i>versionNumber</i> respectively. The <i>versionNumber</i> is
ignored on Windows and Symbian.</p>
<p>Note: In Symbian the path portion of the <i>fileName</i> is
ignored.</p>
<p><b>See also</b> <a href="qlibrary.html#fileName-prop">setFileName</a>().</p>


<h3 class="fn"><a name="setFileNameAndVersion-2" />QLibrary.setFileNameAndVersion (<i>self</i>, QString&#160;<i>fileName</i>, QString&#160;<i>version</i>)</h3><p>Sets the <a href="qlibrary.html#fileName-prop">fileName</a>
property and full version number to <i>fileName</i> and
<i>version</i> respectively. The <i>version</i> parameter is
ignored on Windows and Symbian.</p>
<p>Note: In Symbian the path portion of the <i>fileName</i> is
ignored.</p>
<p>This function was introduced in Qt 4.4.</p>
<p><b>See also</b> <a href="qlibrary.html#fileName-prop">setFileName</a>().</p>


<h3 class="fn"><a name="setLoadHints" />QLibrary.setLoadHints (<i>self</i>, <a href="qlibrary-loadhints.html">LoadHints</a>&#160;<i>hints</i>)</h3><h3 class="fn"><a name="unload" />bool QLibrary.unload (<i>self</i>)</h3><p>Unloads the library and returns true if the library 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="qlibrary.html">QLibrary</a> are
using the same library, the call will fail, and unloading will only
happen when every instance has called unload().</p>
<p>Note that on Mac OS X 10.3 (Panther), dynamic libraries cannot
be unloaded.</p>
<p><b>See also</b> <a href="qlibrary.html#resolve">resolve</a>()
and <a href="qlibrary.html#load">load</a>().</p>
<address><hr /><div align="center"><table border="0" cellspacing="0" width="100%"><tr class="address"><td align="left" width="25%">PyQt&#160;4.10.3 for X11</td><td align="center" width="50%">Copyright &#169; <a href="http://www.riverbankcomputing.com">Riverbank&#160;Computing&#160;Ltd</a> and <a href="http://www.qtsoftware.com">Nokia</a> 2012</td><td align="right" width="25%">Qt&#160;4.8.5</td></tr></table></div></address></body></html>