Sophie

Sophie

distrib > Mageia > 7 > i586 > by-pkgid > 1dd17e0d683ef79b4bb6872bbf359d7f > files > 1429

qt4-doc-4.8.7-26.2.mga7.noarch.rpm

<?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" />
<!-- deployment-plugins.qdoc -->
  <title>Qt 4.8: Deploying Plugins</title>
  <link rel="stylesheet" type="text/css" href="style/style.css" />
  <script src="scripts/jquery.js" type="text/javascript"></script>
  <script src="scripts/functions.js" type="text/javascript"></script>
  <link rel="stylesheet" type="text/css" href="style/superfish.css" />
  <link rel="stylesheet" type="text/css" href="style/narrow.css" />
  <!--[if IE]>
<meta name="MSSmartTagsPreventParsing" content="true">
<meta http-equiv="imagetoolbar" content="no">
<![endif]-->
<!--[if lt IE 7]>
<link rel="stylesheet" type="text/css" href="style/style_ie6.css">
<![endif]-->
<!--[if IE 7]>
<link rel="stylesheet" type="text/css" href="style/style_ie7.css">
<![endif]-->
<!--[if IE 8]>
<link rel="stylesheet" type="text/css" href="style/style_ie8.css">
<![endif]-->

<script src="scripts/superfish.js" type="text/javascript"></script>
<script src="scripts/narrow.js" type="text/javascript"></script>

</head>
<body class="" onload="CheckEmptyAndLoadList();">
 <div class="header" id="qtdocheader">
    <div class="content"> 
    <div id="nav-logo">
      <a href="index.html">Home</a></div>
    <a href="index.html" class="qtref"><span>Qt Reference Documentation</span></a>
    <div id="narrowsearch"></div>
    <div id="nav-topright">
      <ul>
        <li class="nav-topright-home"><a href="http://qt.digia.com/">Qt HOME</a></li>
        <li class="nav-topright-dev"><a href="http://qt-project.org/">DEV</a></li>
        <li class="nav-topright-doc nav-topright-doc-active"><a href="http://qt-project.org/doc/">
          DOC</a></li>
        <li class="nav-topright-blog"><a href="http://blog.qt.digia.com/">BLOG</a></li>
      </ul>
    </div>
    <div id="shortCut">
      <ul>
        <li class="shortCut-topleft-inactive"><span><a href="index.html">Qt 4.8</a></span></li>
        <li class="shortCut-topleft-active"><a href="http://qt-project.org/doc/">ALL VERSIONS        </a></li>
      </ul>
     </div>
 <ul class="sf-menu" id="narrowmenu"> 
             <li><a href="#">API Lookup</a> 
                 <ul> 
                     <li><a href="classes.html">Class index</a></li> 
           <li><a href="functions.html">Function index</a></li> 
           <li><a href="modules.html">Modules</a></li> 
           <li><a href="namespaces.html">Namespaces</a></li> 
           <li><a href="qtglobal.html">Global Declarations</a></li> 
           <li><a href="qdeclarativeelements.html">QML elements</a></li> 
             </ul> 
             </li> 
             <li><a href="#">Qt Topics</a> 
                 <ul> 
                        <li><a href="qt-basic-concepts.html">Programming with Qt</a></li>  
                        <li><a href="qtquick.html">Device UIs &amp; Qt Quick</a></li>  
                        <li><a href="qt-gui-concepts.html">UI Design with Qt</a></li>  
                        <li><a href="supported-platforms.html">Supported Platforms</a></li>  
                        <li><a href="technology-apis.html">Qt and Key Technologies</a></li>  
                        <li><a href="best-practices.html">How-To's and Best Practices</a></li>  
              </ul> 
                 </li> 
                 <li><a href="#">Examples</a> 
                     <ul> 
                       <li><a href="all-examples.html">Examples</a></li> 
                       <li><a href="tutorials.html">Tutorials</a></li> 
                       <li><a href="demos.html">Demos</a></li> 
                       <li><a href="qdeclarativeexamples.html">QML Examples</a></li> 
                </ul> 
                     </li> 
                 </ul> 
    </div>
  </div>
  <div class="wrapper">
    <div class="hd">
      <span></span>
    </div>
    <div class="bd group">
      <div class="sidebar">
        <div class="searchlabel">
          Search index:</div>
        <div class="search" id="sidebarsearch">
          <form id="qtdocsearch" action="" onsubmit="return false;">
            <fieldset>
              <input type="text" name="searchstring" id="pageType" value="" />
 <div id="resultdialog"> 
 <a href="#" id="resultclose">Close</a> 
 <p id="resultlinks" class="all"><a href="#" id="showallresults">All</a> | <a href="#" id="showapiresults">API</a> | <a href="#" id="showarticleresults">Articles</a> | <a href="#" id="showexampleresults">Examples</a></p> 
 <p id="searchcount" class="all"><span id="resultcount"></span><span id="apicount"></span><span id="articlecount"></span><span id="examplecount"></span>&nbsp;results:</p> 
 <ul id="resultlist" class="all"> 
 </ul> 
 </div> 
            </fieldset>
          </form>
        </div>
        <div class="box first bottombar" id="lookup">
          <h2 title="API Lookup"><span></span>
            API Lookup</h2>
          <div  id="list001" class="list">
          <ul id="ul001" >
              <li class="defaultLink"><a href="classes.html">Class index</a></li>
              <li class="defaultLink"><a href="functions.html">Function index</a></li>
              <li class="defaultLink"><a href="modules.html">Modules</a></li>
              <li class="defaultLink"><a href="namespaces.html">Namespaces</a></li>
              <li class="defaultLink"><a href="qtglobal.html">Global Declarations</a></li>
              <li class="defaultLink"><a href="qdeclarativeelements.html">QML elements</a></li>
            </ul> 
          </div>
        </div>
        <div class="box bottombar" id="topics">
          <h2 title="Qt Topics"><span></span>
            Qt Topics</h2>
          <div id="list002" class="list">
            <ul id="ul002" >
               <li class="defaultLink"><a href="qt-basic-concepts.html">Programming with Qt</a></li> 
               <li class="defaultLink"><a href="qtquick.html">Device UIs &amp; Qt Quick</a></li> 
               <li class="defaultLink"><a href="qt-gui-concepts.html">UI Design with Qt</a></li> 
               <li class="defaultLink"><a href="supported-platforms.html">Supported Platforms</a></li>  
               <li class="defaultLink"><a href="technology-apis.html">Qt and Key Technologies</a></li> 
               <li class="defaultLink"><a href="best-practices.html">How-To's and Best Practices</a></li> 
            </ul>  
          </div>
        </div>
        <div class="box" id="examples">
          <h2 title="Examples"><span></span>
            Examples</h2>
          <div id="list003" class="list">
        <ul id="ul003">
              <li class="defaultLink"><a href="all-examples.html">Examples</a></li>
              <li class="defaultLink"><a href="tutorials.html">Tutorials</a></li>
              <li class="defaultLink"><a href="demos.html">Demos</a></li>
              <li class="defaultLink"><a href="qdeclarativeexamples.html">QML Examples</a></li>
            </ul> 
          </div>
        </div>
      </div>
      <div class="wrap">
        <div class="toolbar">
          <div class="breadcrumb toolblock">
            <ul>
              <li class="first"><a href="index.html">Home</a></li>
              <!--  Breadcrumbs go here -->
<li>Deploying Plugins</li>
            </ul>
          </div>
          <div class="toolbuttons toolblock">
            <ul>
              <li id="smallA" class="t_button">A</li>
              <li id="medA" class="t_button active">A</li>
              <li id="bigA" class="t_button">A</li>
              <li id="print" class="t_button"><a href="javascript:this.print();">
                <span>Print</span></a></li>
            </ul>
        </div>
        </div>
        <div class="content mainContent">
<div class="toc">
<h3><a name="toc">Contents</a></h3>
<ul>
<li class="level1"><a href="#the-plugin-directory">The Plugin Directory</a></li>
<li class="level1"><a href="#loading-and-verifying-plugins-dynamically">Loading and Verifying Plugins Dynamically</a></li>
<li class="level2"><a href="#the-build-key">The Build Key</a></li>
<li class="level1"><a href="#the-plugin-cache">The Plugin Cache</a></li>
<li class="level1"><a href="#debugging-plugins">Debugging Plugins</a></li>
</ul>
</div>
<h1 class="title">Deploying Plugins</h1>
<span class="subtitle"></span>
<!-- $$$deployment-plugins.html-description -->
<div class="descr"> <a name="details"></a>
<p>This document explains how to deploy plugin libraries that Qt or your application should load at runtime. If you use <a href="plugins-howto.html#static-plugins">static plugins</a>, then the plugin code is already part of your application executable, and no separate deployment steps are required.</p>
<a name="the-plugin-directory"></a>
<h2>The Plugin Directory</h2>
<p>When the application is run, Qt will first treat the application's executable directory as the <tt>pluginsbase</tt>. For example if the application is in <tt>C:\Program Files\MyApp</tt> and has a style plugin, Qt will look in <tt>C:\Program Files\MyApp\styles</tt>. (See <a href="qcoreapplication.html#applicationDirPath">QCoreApplication::applicationDirPath</a>() for how to find out where the application's executable is.) Qt will also look in the directory specified by QLibraryInfo::location(<a href="qlibraryinfo.html#LibraryLocation-enum">QLibraryInfo::PluginsPath</a>), which typically is located in <tt>QTDIR/plugins</tt> (where <tt>QTDIR</tt> is the directory where Qt is installed). If you want Qt to look in additional places you can add as many paths as you need with calls to <a href="qcoreapplication.html#addLibraryPath">QCoreApplication::addLibraryPath</a>(). And if you want to set your own path or paths you can use <a href="qcoreapplication.html#setLibraryPaths">QCoreApplication::setLibraryPaths</a>(). You can also use a <tt>qt.conf</tt> file to override the hard-coded paths that are compiled into the Qt library. For more information, see the <a href="qt-conf.html">Using qt.conf</a> documentation. Yet another possibility is to set the <tt>QT_PLUGIN_PATH</tt> environment variable before running the application. If set, Qt will look for plugins in the paths (separated by the system path separator) specified in the variable.</p>
<a name="loading-and-verifying-plugins-dynamically"></a>
<h2>Loading and Verifying Plugins Dynamically</h2>
<p>When loading plugins, the Qt library does some sanity checking to determine whether or not the plugin can be loaded and used. This provides the ability to have multiple versions and configurations of the Qt library installed side by side.</p>
<ul>
<li>Plugins linked with a Qt library that has a higher version number will not be loaded by a library with a lower version number.<br /><p><b>Example:</b> Qt 4.3&#x2e;0 will <i>not</i> load a plugin built with Qt 4.3&#x2e;1&#x2e;</p>
</li>
<li>Plugins linked with a Qt library that has a lower major version number will not be loaded by a library with a higher major version number.<br /><p><b>Example:</b> Qt 4.3&#x2e;1 will <i>not</i> load a plugin built with Qt 3.3&#x2e;1&#x2e; <br /> <b>Example:</b> Qt 4.3&#x2e;1 will load plugins built with Qt 4.3&#x2e;0 and Qt 4.2&#x2e;3&#x2e;</p>
</li>
<li>The Qt library and all plugins are built using a <i>build key</i>. The build key in the Qt library is examined against the build key in the plugin, and if they match, the plugin is loaded. If the build keys do not match, then the Qt library refuses to load the plugin.<br /><p><b>Rationale:</b> See the <a href="#the-build-key">The Build Key</a> section below.</p>
</li>
</ul>
<p>When building plugins to extend an application, it is important to ensure that the plugin is configured in the same way as the application. This means that if the application was built in release mode, plugins should be built in release mode, too.</p>
<p>If you configure Qt to be built in both debug and release modes, but only build applications in release mode, you need to ensure that your plugins are also built in release mode. By default, if a debug build of Qt is available, plugins will <i>only</i> be built in debug mode. To force the plugins to be built in release mode, add the following line to the plugin's project file:</p>
<pre class="cpp"> CONFIG += release</pre>
<p>This will ensure that the plugin is compatible with the version of the library used in the application.</p>
<a name="the-build-key"></a>
<h3>The Build Key</h3>
<p>When loading plugins, Qt checks the build key of each plugin against its own configuration to ensure that only compatible plugins are loaded; any plugins that are configured differently are not loaded.</p>
<p>The build key contains the following information:</p>
<ul>
<li>Architecture, operating system and compiler.<p><i>Rationale:</i> In cases where different versions of the same compiler do not produce binary compatible code, the version of the compiler is also present in the build key.</p>
</li>
<li>Configuration of the Qt library. The configuration is a list of the missing features that affect the available API in the library.<p><i>Rationale:</i> Two different configurations of the same version of the Qt library are not binary compatible. The Qt library that loads the plugin uses the list of (missing) features to determine if the plugin is binary compatible.</p>
<p><i>Note:</i> There are cases where a plugin can use features that are available in two different configurations. However, the developer writing plugins would need to know which features are in use, both in their plugin and internally by the utility classes in Qt. The Qt library would require complex feature and dependency queries and verification when loading plugins. Requiring this would place an unnecessary burden on the developer, and increase the overhead of loading a plugin. To reduce both development time and application runtime costs, a simple string comparision of the build keys is used.</p>
</li>
<li>Optionally, an extra string may be specified on the configure script command line.<p><i>Rationale:</i> When distributing binaries of the Qt library with an application, this provides a way for developers to write plugins that can only be loaded by the library with which the plugins were linked.</p>
</li>
</ul>
<p>For debugging purposes, it is possible to override the run-time build key checks by configuring Qt with the <tt>QT_NO_PLUGIN_CHECK</tt> preprocessor macro defined.</p>
<a name="the-plugin-cache"></a>
<h2>The Plugin Cache</h2>
<p>In order to speed up loading and validation of plugins, some of the information that is collected when plugins are loaded is cached through <a href="qsettings.html">QSettings</a>. This includes information about whether or not a plugin was successfully loaded, 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, and the cache entry itself is updated with the new result.</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>Sometimes, when developing plugins, it is necessary to remove entries from the plugin cache. Since Qt uses <a href="qsettings.html">QSettings</a> to manage the plugin cache, the locations of plugins are platform-dependent; see <a href="qsettings.html#platform-specific-notes">the QSettings documentation</a> for more information about each platform.</p>
<p>For example, on Windows the entries are stored in the registry, and the paths for each plugin will typically begin with either of these two strings:</p>
<pre class="cpp"> HKEY_CURRENT_USER\Software\Trolltech\OrganizationDefaults\Qt Plugin Cache 4.2.debug
 HKEY_CURRENT_USER\Software\Trolltech\OrganizationDefaults\Qt Plugin Cache 4.2.false</pre>
<a name="debugging-plugins"></a>
<h2>Debugging Plugins</h2>
<p>There are a number of issues that may prevent correctly-written plugins from working with the applications that are designed to use them. Many of these are related to differences in the way that plugins and applications have been built, often arising from separate build systems and processes.</p>
<p>The following table contains descriptions of the common causes of problems developers experience when creating plugins:</p>
<table class="generic">
<thead><tr class="qt-style"><th >Problem</th><th >Cause</th><th >Solution</th></tr></thead>
<tr valign="top" class="odd"><td >Plugins sliently fail to load even when opened directly by the application. <i>Qt Designer</i> shows the plugin libraries in its <b>Help|About Plugins</b> dialog, but no plugins are listed under each of them.</td><td >The application and its plugins are built in different modes.</td><td >Either share the same build information or build the plugins in both debug and release modes by appending the <tt>debug_and_release</tt> to the <a href="qmake-variable-reference.html#config">CONFIG</a> variable in each of their project files.</td></tr>
<tr valign="top" class="even"><td >A valid plugin that replaces an invalid (or broken) plugin fails to load.</td><td >The entry for the plugin in the plugin cache indicates that the original plugin could not be loaded, causing Qt to ignore the replacement.</td><td >Either ensure that the plugin's timestamp is updated, or delete the entry in the <a href="#the-plugin-cache">plugin cache</a>.</td></tr>
</table>
<p>You can also use the <tt>QT_DEBUG_PLUGINS</tt> environment variable to obtain diagnostic information from Qt about each plugin it tries to load. Set this variable to a non-zero value in the environment from which your application is launched.</p>
</div>
<!-- @@@deployment-plugins.html -->
      </div>
    </div>
    </div> 
    <div class="ft">
      <span></span>
    </div>
  </div> 
  <div class="footer">
    <p>
      <acronym title="Copyright">&copy;</acronym> 2015 The Qt Company Ltd.
      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>
      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. <a title="Privacy Policy"
      href="http://en.gitorious.org/privacy_policy/">Privacy Policy</a></p>
  </div>

  <script src="scripts/functions.js" type="text/javascript"></script>
</body>
</html>