Sophie

Sophie

distrib > Mageia > 7 > armv7hl > media > core-updates > by-pkgid > d5e62c01ae8d1e579463c6a871dd44bf > files > 628

qtbase5-doc-5.12.6-2.mga7.noarch.rpm

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<!-- qpluginloader.cpp -->
  <title>QPluginLoader Class | Qt Core 5.12.6</title>
  <link rel="stylesheet" type="text/css" href="style/offline-simple.css" />
  <script type="text/javascript">
    document.getElementsByTagName("link").item(0).setAttribute("href", "style/offline.css");
    // loading style sheet breaks anchors that were jumped to before
    // so force jumping to anchor again
    setTimeout(function() {
        var anchor = location.hash;
        // need to jump to different anchor first (e.g. none)
        location.hash = "#";
        setTimeout(function() {
            location.hash = anchor;
        }, 0);
    }, 0);
  </script>
</head>
<body>
<div class="header" id="qtdocheader">
  <div class="main">
    <div class="main-rounded">
      <div class="navigationbar">
        <table><tr>
<td >Qt 5.12</td><td ><a href="qtcore-index.html">Qt Core</a></td><td ><a href="qtcore-module.html">C++ Classes</a></td><td >QPluginLoader</td></tr></table><table class="buildversion"><tr>
<td id="buildversion" width="100%" align="right"><a href="qtcore-index.html">Qt 5.12.6 Reference Documentation</a></td>
        </tr></table>
      </div>
    </div>
<div class="content">
<div class="line">
<div class="content mainContent">
<div class="sidebar">
<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>
<div class="sidebar-content" id="sidebar-content"></div></div>
<h1 class="title">QPluginLoader Class</h1>
<!-- $$$QPluginLoader-brief -->
<p>The <a href="qpluginloader.html">QPluginLoader</a> class loads a plugin at run-time. <a href="#details">More...</a></p>
<!-- @@@QPluginLoader -->
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> Header:</td><td class="memItemRight bottomAlign">   <span class="preprocessor">#include &lt;QPluginLoader&gt;</span>
</td></tr><tr><td class="memItemLeft rightAlign topAlign"> qmake:</td><td class="memItemRight bottomAlign"> QT += core</td></tr><tr><td class="memItemLeft rightAlign topAlign"> Inherits:</td><td class="memItemRight bottomAlign"> <a href="qobject.html">QObject</a></td></tr></table></div><ul>
<li><a href="qpluginloader-members.html">List of all members, including inherited members</a></li>
<li><a href="qpluginloader-obsolete.html">Obsolete members</a></li>
</ul>
<p><b>Note:</b> All functions in this class are reentrant.</p>
<a name="properties"></a>
<h2 id="properties">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 id="public-functions">Public Functions</h2>
<div class="table"><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> = nullptr)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> </td><td class="memItemRight bottomAlign"><b><a href="qpluginloader.html#QPluginLoader-1">QPluginLoader</a></b>(const QString &amp;<i>fileName</i>, QObject *<i>parent</i> = nullptr)</td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> virtual </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"> QJsonObject </td><td class="memItemRight bottomAlign"><b><a href="qpluginloader.html#metaData">metaData</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></div>
<ul>
<li class="fn">32 public functions inherited from <a href="qobject.html#public-functions">QObject</a></li>
</ul>
<a name="static-public-members"></a>
<h2 id="static-public-members">Static Public Members</h2>
<div class="table"><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>
<tr><td class="memItemLeft rightAlign topAlign"> const QMetaObject </td><td class="memItemRight bottomAlign"><b><a href="qpluginloader.html#staticMetaObject-var">staticMetaObject</a></b></td></tr>
<tr><td class="memItemLeft rightAlign topAlign"> QVector&lt;QStaticPlugin&gt; </td><td class="memItemRight bottomAlign"><b><a href="qpluginloader.html#staticPlugins">staticPlugins</a></b>()</td></tr>
</table></div>
<ul>
<li class="fn">10 static public members inherited from <a href="qobject.html#static-public-members">QObject</a></li>
</ul>
<a name="related-non-members"></a>
<h2 id="related-non-members">Related Non-Members</h2>
<div class="table"><table class="alignedsummary">
<tr><td class="memItemLeft rightAlign topAlign"> void </td><td class="memItemRight bottomAlign"><b><a href="qpluginloader.html#qRegisterStaticPluginFunction">qRegisterStaticPluginFunction</a></b>(QStaticPlugin <i>plugin</i>)</td></tr>
</table></div>
<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">2 signals inherited from <a href="qobject.html#signals">QObject</a></li>
<li class="fn">9 protected functions inherited from <a href="qobject.html#protected-functions">QObject</a></li>
</ul>
<a name="details"></a>
<!-- $$$QPluginLoader-description -->
<div class="descr">
<h2 id="details">Detailed Description</h2>
<p>The <a href="qpluginloader.html">QPluginLoader</a> class loads a plugin at run-time.</p>
<p><a href="qpluginloader.html">QPluginLoader</a> provides access to a Qt plugin. 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><a href="qpluginloader.html">QPluginLoader</a> checks that a plugin is linked against the same version of Qt as the application.</li>
<li><a href="qpluginloader.html">QPluginLoader</a> 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 <a href="qpluginloader.html">QPluginLoader</a> 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 <a href="qpluginloader.html">QPluginLoader</a> can be used to access the same physical plugin.</p>
<p>Once loaded, plugins remain in memory until all instances of <a href="qpluginloader.html">QPluginLoader</a> 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 <a href="qpluginloader.html">QPluginLoader</a> 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>See How to Create Qt Plugins for more information about how to make your application extensible through plugins.</p>
<p>Note that the <a href="qpluginloader.html">QPluginLoader</a> 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>
</div>
<p><b>See also </b><a href="qlibrary.html">QLibrary</a> and <a href="../qtwidgets/qtwidgets-tools-plugandpaint-app-example.html">Plug &amp; Paint Example</a>.</p>
<!-- @@@QPluginLoader -->
<div class="prop">
<h2>Property Documentation</h2>
<!-- $$$fileName-prop$$$fileName$$$setFileNameconstQString& -->
<h3 class="fn" id="fileName-prop"><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>We recommend omitting the file's suffix in the file name, since <a href="qpluginloader.html">QPluginLoader</a> will automatically look for the file with the appropriate suffix (see <a href="qlibrary.html#isLibrary">QLibrary::isLibrary</a>()).</p>
<p>When loading the plugin, <a href="qpluginloader.html">QPluginLoader</a> searches in the current directory and in all plugin locations specified by <a href="qcoreapplication.html#libraryPaths">QCoreApplication::libraryPaths</a>(), unless the file name has an absolute path. After loading the plugin successfully, fileName() returns the fully-qualified file name of the plugin, including the full path to the plugin if one was given in the constructor or passed to setFileName().</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><b>Access functions:</b></p>
<div class="table"><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></div>
<p><b>See also </b><a href="qpluginloader.html#load">load</a>().</p>
<!-- @@@fileName -->
<!-- $$$loadHints-prop$$$loadHints$$$setLoadHintsQLibrary::LoadHints -->
<h3 class="fn" id="loadHints-prop"><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>Give the <a href="qpluginloader.html#load">load</a>() 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 since Qt 5.7, <a href="qlibrary.html#LoadHint-enum">QLibrary::PreventUnloadHint</a> is 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>
<div class="table"><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></div>
<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" id="QPluginLoader"><a name="QPluginLoader"></a>QPluginLoader::<span class="name">QPluginLoader</span>(<span class="type"><a href="qobject.html#QObject">QObject</a></span> *<i>parent</i> = nullptr)</h3>
<p>Constructs a plugin loader with the given <i>parent</i>.</p>
<!-- @@@QPluginLoader -->
<!-- $$$QPluginLoader$$$QPluginLoaderconstQString&QObject* -->
<h3 class="fn" id="QPluginLoader-1"><a name="QPluginLoader-1"></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">QObject</a></span> *<i>parent</i> = nullptr)</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; <code>.so</code> on Unix, - <code>.dylib</code> on macOS and iOS, and <code>.dll</code> on Windows. The suffix can be verified with <a href="qlibrary.html#isLibrary">QLibrary::isLibrary</a>().</p>
<p><b>See also </b><a href="qpluginloader.html#fileName-prop">setFileName</a>().</p>
<!-- @@@QPluginLoader -->
<!-- $$$~QPluginLoader[overload1]$$$~QPluginLoader -->
<h3 class="fn" id="dtor.QPluginLoader"><a name="dtor.QPluginLoader"></a><code>[virtual] </code>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" id="errorString"><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" id="instance"><a name="instance"></a><span class="type"><a href="qobject.html#QObject">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 <code>nullptr</code> 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" id="isLoaded"><a name="isLoaded"></a><span class="type">bool</span> QPluginLoader::<span class="name">isLoaded</span>() const</h3>
<p>Returns <code>true</code> if the plugin is loaded; otherwise returns <code>false</code>.</p>
<p><b>See also </b><a href="qpluginloader.html#load">load</a>().</p>
<!-- @@@isLoaded -->
<!-- $$$load[overload1]$$$load -->
<h3 class="fn" id="load"><a name="load"></a><span class="type">bool</span> QPluginLoader::<span class="name">load</span>()</h3>
<p>Loads the plugin and returns <code>true</code> if the plugin was loaded successfully; otherwise returns <code>false</code>. 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 -->
<!-- $$$metaData[overload1]$$$metaData -->
<h3 class="fn" id="metaData"><a name="metaData"></a><span class="type"><a href="qjsonobject.html">QJsonObject</a></span> QPluginLoader::<span class="name">metaData</span>() const</h3>
<p>Returns the meta data for this plugin. The meta data is data specified in a json format using the <a href="qtplugin.html#Q_PLUGIN_METADATA">Q_PLUGIN_METADATA</a>() macro when compiling the plugin.</p>
<p>The meta data can be queried in a fast and inexpensive way without actually loading the plugin. This makes it possible to e.g&#x2e; store capabilities of the plugin in there, and make the decision whether to load the plugin dependent on this meta data.</p>
<!-- @@@metaData -->
<!-- $$$staticInstances[overload1]$$$staticInstances -->
<h3 class="fn" id="staticInstances"><a name="staticInstances"></a><code>[static] </code><span class="type"><a href="qobject.html#QObjectList-typedef">QObjectList</a></span> QPluginLoader::<span class="name">staticInstances</span>()</h3>
<p>Returns a list of static plugin instances (root components) held by the plugin loader.</p>
<p><b>See also </b><a href="qpluginloader.html#staticPlugins">staticPlugins</a>().</p>
<!-- @@@staticInstances -->
<!-- $$$staticPlugins[overload1]$$$staticPlugins -->
<h3 class="fn" id="staticPlugins"><a name="staticPlugins"></a><code>[static] </code><span class="type"><a href="qvector.html">QVector</a></span>&lt;<span class="type"><a href="qstaticplugin.html">QStaticPlugin</a></span>&gt; QPluginLoader::<span class="name">staticPlugins</span>()</h3>
<p>Returns a list of QStaticPlugins held by the plugin loader. The function is similar to <a href="qpluginloader.html#staticInstances">staticInstances</a>() with the addition that a <a href="qstaticplugin.html">QStaticPlugin</a> also contains meta data information.</p>
<p><b>See also </b><a href="qpluginloader.html#staticInstances">staticInstances</a>().</p>
<!-- @@@staticPlugins -->
<!-- $$$unload[overload1]$$$unload -->
<h3 class="fn" id="unload"><a name="unload"></a><span class="type">bool</span> QPluginLoader::<span class="name">unload</span>()</h3>
<p>Unloads the plugin and returns <code>true</code> if the plugin could be unloaded; otherwise returns <code>false</code>.</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>
<!-- $$$qRegisterStaticPluginFunction[overload1]$$$qRegisterStaticPluginFunctionQStaticPlugin -->
<h3 class="fn" id="qRegisterStaticPluginFunction"><a name="qRegisterStaticPluginFunction"></a><span class="type">void</span> <span class="name">qRegisterStaticPluginFunction</span>(<span class="type"><a href="qstaticplugin.html">QStaticPlugin</a></span> <i>plugin</i>)</h3>
<p>Registers the <i>plugin</i> specified with the plugin loader, and is used by <a href="qtplugin.html#Q_IMPORT_PLUGIN">Q_IMPORT_PLUGIN</a>().</p>
<p>This function was introduced in  Qt 5.0.</p>
<!-- @@@qRegisterStaticPluginFunction -->
</div>
        </div>
       </div>
   </div>
   </div>
</div>
<div class="footer">
   <p>
   <acronym title="Copyright">&copy;</acronym> 2019 The Qt Company Ltd.
   Documentation contributions included herein are the copyrights of
   their respective owners.<br/>    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.<br/>    Qt and respective logos are trademarks of The Qt Company Ltd.     in Finland and/or other countries worldwide. All other trademarks are property
   of their respective owners. </p>
</div>
</body>
</html>