Редактирование: Qt:Документация 4.3.2/plugins-howto

Материал из Wiki.crossplatform.ru

Перейти к: навигация, поиск
Внимание: Вы не представились системе. Ваш IP-адрес будет записан в историю изменений этой страницы.
Правка может быть отменена. Пожалуйста, просмотрите сравнение версий, чтобы убедиться, что это именно те изменения, которые вас интересуют, и нажмите «Записать страницу», чтобы изменения вступили в силу.
Текущая версия Ваш текст
Строка 2: Строка 2:
=How to Create Qt Plugins<br />=
=How to Create Qt Plugins<br />=
-
<div id="qt-debug-plugins"></div><div id="qt-no-plugin-check"></div>
 
Qt provides two APIs for creating plugins:
Qt provides two APIs for creating plugins:
Строка 14: Строка 13:
If you want to provide plugins for use with ''Qt Designer'', see the [[Qt:Документация 4.3.2/qtdesigner | QtDesigner]] module documentation.
If you want to provide plugins for use with ''Qt Designer'', see the [[Qt:Документация 4.3.2/qtdesigner | QtDesigner]] module documentation.
-
Topics:
 
-
*[[#the-higher-level-api-writing-qt-extensions | The Higher-Level API: Writing Qt Extensions]]
 
-
*[[#the-lower-level-api-extending-qt-applications | The Lower-Level API: Extending Qt Applications]]
 
-
*[[#loading-and-verifying-plugins-dynamically | Loading and Verifying Plugins Dynamically]]
 
-
**[[#the-build-key | The Build Key]]
 
-
 
-
*[[#static-plugins | Static Plugins]]
 
-
*[[#the-plugin-cache | The Plugin Cache]]
 
-
*[[#debugging-plugins | Debugging Plugins]]
 
-
<div id="the-higher-level-api-writing-qt-extensions"></div>
 
==The Higher-Level API: Writing Qt Extensions==
==The Higher-Level API: Writing Qt Extensions==
Writing a plugin that extends Qt itself is achieved by subclassing the appropriate plugin base class, implementing a few functions, and adding a macro.
Writing a plugin that extends Qt itself is achieved by subclassing the appropriate plugin base class, implementing a few functions, and adding a macro.
Строка 132: Строка 121:
The [[Qt:Документация 4.3.2/tools-styleplugin | Style Plugin Example]] shows how to implement a plugin that extends the [[Qt:Документация 4.3.2/qstyleplugin | QStylePlugin]] base class.
The [[Qt:Документация 4.3.2/tools-styleplugin | Style Plugin Example]] shows how to implement a plugin that extends the [[Qt:Документация 4.3.2/qstyleplugin | QStylePlugin]] base class.
-
<div id="the-lower-level-api-extending-qt-applications"></div>
+
 
==The Lower-Level API: Extending Qt Applications==
==The Lower-Level API: Extending Qt Applications==
Not only Qt itself but also Qt application can be extended through plugins. This requires the application to detect and load plugins using [[Qt:Документация 4.3.2/qpluginloader | QPluginLoader]]. In that context, plugins may provide arbitrary functionality and are not limited to database drivers, image formats, text codecs, styles, and the other types of plugin that extend Qt's functionality.
Not only Qt itself but also Qt application can be extended through plugins. This requires the application to detect and load plugins using [[Qt:Документация 4.3.2/qpluginloader | QPluginLoader]]. In that context, plugins may provide arbitrary functionality and are not limited to database drivers, image formats, text codecs, styles, and the other types of plugin that extend Qt's functionality.
Строка 181: Строка 170:
  };</source>  
  };</source>  
The [[Qt:Документация 4.3.2/tools-plugandpaint | Plug &amp; Paint]] example documentation explains this process in detail. See also [[Qt:Документация 4.3.2/designer-creating-custom-widgets | Creating Custom Widgets for Qt Designer]] for information about issues that are specific to ''Qt Designer''. You can also take a look at the [[Qt:Документация 4.3.2/tools-echoplugin | Echo Plugin Example]] is a more trivial example on how to implement a plugin that extends Qt applications.
The [[Qt:Документация 4.3.2/tools-plugandpaint | Plug &amp; Paint]] example documentation explains this process in detail. See also [[Qt:Документация 4.3.2/designer-creating-custom-widgets | Creating Custom Widgets for Qt Designer]] for information about issues that are specific to ''Qt Designer''. You can also take a look at the [[Qt:Документация 4.3.2/tools-echoplugin | Echo Plugin Example]] is a more trivial example on how to implement a plugin that extends Qt applications.
-
<div id="loading-and-verifying-plugins-dynamically"></div>
+
 
==Loading and Verifying Plugins Dynamically==
==Loading and Verifying Plugins Dynamically==
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.
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.
Строка 193: Строка 182:
<source lang="cpp-qt"> CONFIG += release</source>  
<source lang="cpp-qt"> CONFIG += release</source>  
This will ensure that the plugin is compatible with the version of the library used in the application.
This will ensure that the plugin is compatible with the version of the library used in the application.
-
<div id="the-build-key"></div>
+
 
===The Build Key===
===The Build Key===
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.
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.
Строка 204: Строка 193:
For debugging purposes, it is possible to override the run-time build key checks by setting the <tt>QT_NO_PLUGIN_CHECK</tt> environment variable to a non-zero value in the environment from which your application is launched.
For debugging purposes, it is possible to override the run-time build key checks by setting the <tt>QT_NO_PLUGIN_CHECK</tt> environment variable to a non-zero value in the environment from which your application is launched.
-
<div id="static-plugins"></div>
+
 
==Static Plugins==
==Static Plugins==
Plugins can be linked statically against your application. If you build the static version of Qt, this is the only option for including Qt's predefined plugins.
Plugins can be linked statically against your application. If you build the static version of Qt, this is the only option for including Qt's predefined plugins.
Строка 343: Строка 332:
See the [[Qt:Документация 4.3.2/tools-plugandpaint | Plug &amp; Paint]] example and the associated [[Qt:Документация 4.3.2/tools-plugandpaintplugins-basictools | Basic Tools]] plugin for details on how to do this.
See the [[Qt:Документация 4.3.2/tools-plugandpaint | Plug &amp; Paint]] example and the associated [[Qt:Документация 4.3.2/tools-plugandpaintplugins-basictools | Basic Tools]] plugin for details on how to do this.
-
<div id="the-plugin-cache"></div>
+
 
==The Plugin Cache==
==The Plugin Cache==
In order to speed up loading and validation of plugins, some of the information that is collected when plugins are loaded is cached through [[Qt:Документация 4.3.2/qsettings | 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.
In order to speed up loading and validation of plugins, some of the information that is collected when plugins are loaded is cached through [[Qt:Документация 4.3.2/qsettings | 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.
Строка 353: Строка 342:
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:
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:
<source lang="cpp-qt"> HKEY_CURRENT_USER\Software\Trolltech\OrganizationDefaults\Qt Plugin Cache 4.2.debug
<source lang="cpp-qt"> HKEY_CURRENT_USER\Software\Trolltech\OrganizationDefaults\Qt Plugin Cache 4.2.debug
-
  HKEY_CURRENT_USER\Software\Trolltech\OrganizationDefaults\Qt Plugin Cache 4.2.false</source> <div id="debugging-plugins"></div>
+
  HKEY_CURRENT_USER\Software\Trolltech\OrganizationDefaults\Qt Plugin Cache 4.2.false</source>  
==Debugging Plugins==
==Debugging Plugins==
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.
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.

Пожалуйста, обратите внимание, что все ваши добавления могут быть отредактированы или удалены другими участниками. Если вы не хотите, чтобы кто-либо изменял ваши тексты, не помещайте их сюда.
Вы также подтверждаете, что являетесь автором вносимых дополнений, или скопировали их из источника, допускающего свободное распространение и изменение своего содержимого (см. Wiki.crossplatform.ru:Авторское право). НЕ РАЗМЕЩАЙТЕ БЕЗ РАЗРЕШЕНИЯ ОХРАНЯЕМЫЕ АВТОРСКИМ ПРАВОМ МАТЕРИАЛЫ!


Шаблоны, использованные на текущей версии страницы: