Deploying PluginsThis document explains how to deploy plugin libraries that Qt or your application should load at runtime. If you use static plugins, then the plugin code is already part of your application executable, and no separate deployment steps are required. The Plugin DirectoryWhen the application is run, Qt will first treat the application's executable directory as the pluginsbase. For example if the application is in C:\Program Files\MyApp and has a style plugin, Qt will look in C:\Program Files\MyApp\styles. (See QCoreApplication::applicationDirPath() for how to find out where the application's executable is.) Qt will also look in the directory specified by QLibraryInfo::location(QLibraryInfo::PluginsPath), which typically is located in QTDIR/plugins (where QTDIR 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 QCoreApplication::addLibraryPath(). And if you want to set your own path or paths you can use QCoreApplication::setLibraryPaths(). You can also use a qt.conf file to override the hard-coded paths that are compiled into the Qt library. For more information, see the Using qt.conf documentation. Yet another possibility is to set the QT_PLUGIN_PATH 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. Loading and Verifying Plugins DynamicallyWhen 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.
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. 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 only 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: CONFIG += release This will ensure that the plugin is compatible with the version of the library used in the application. The Build KeyWhen 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. The build key contains the following information:
For debugging purposes, it is possible to override the run-time build key checks by configuring Qt with the QT_NO_PLUGIN_CHECK preprocessor macro defined. The Plugin CacheIn order to speed up loading and validation of plugins, some of the information that is collected when plugins are loaded is cached through QSettings. 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 "last modified" 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. 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. Sometimes, when developing plugins, it is necessary to remove entries from the plugin cache. Since Qt uses QSettings to manage the plugin cache, the locations of plugins are platform-dependent; see the QSettings documentation for more information about each platform. 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: HKEY_CURRENT_USER\Software\Trolltech\OrganizationDefaults\Qt Plugin Cache 4.2.debug HKEY_CURRENT_USER\Software\Trolltech\OrganizationDefaults\Qt Plugin Cache 4.2.false Debugging PluginsThere 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. The following table contains descriptions of the common causes of problems developers experience when creating plugins:
You can also use the QT_DEBUG_PLUGINS 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. |
Cette page est une traduction d'une page de la documentation de Qt, écrite par Nokia Corporation and/or its subsidiary(-ies). Les éventuels problèmes résultant d'une mauvaise traduction ne sont pas imputables à Nokia. | Qt 4.8 | |
Copyright © 2012 Developpez LLC. Tous droits réservés Developpez LLC. Aucune reproduction, même partielle, ne peut être faite de ce site et de l'ensemble de son contenu : textes, documents et images sans l'autorisation expresse de Developpez LLC. Sinon, vous encourez selon la loi jusqu'à 3 ans de prison et jusqu'à 300 000 E de dommages et intérêts. Cette page est déposée à la SACD. | ||
Vous avez déniché une erreur ? Un bug ? Une redirection cassée ? Ou tout autre problème, quel qu'il soit ? Ou bien vous désirez participer à ce projet de traduction ? N'hésitez pas à nous contacter ou par MP ! |
Copyright © 2000-2012 - www.developpez.com