IPlugin Class
(ExtensionSystem::IPlugin)The IPlugin class is the base class for all plugins. More...
| Header: | #include <IPlugin> |
| Inherited By: | ProjectExplorer::ProjectExplorerPlugin and VcsBase::VcsBasePlugin |
Detailed Description
The IPlugin class is an abstract class that must be implemented once for each plugin. A plugin consists of two parts: A description file, and a library that at least contains the IPlugin implementation.
Plugin Specification
A plugin needs to provide a plugin specification file in addition to the actual plugin library, so the plugin manager can find the plugin, resolve its dependencies, and load it. For more information, see Plugin Specifications.
Plugin Implementation
Plugins must provide one implementation of the IPlugin class, located in a library that matches the name attribute given in their XML description. The IPlugin implementation must be exported and made known to Qt's plugin system, using the Q_PLUGIN_METADATA macro with an IID set to "org.qt-project.Qt.QtCreatorPlugin".
After the plugins' XML files have been read, and dependencies have been found, the plugin loading is done in three phases:
- All plugin libraries are loaded in root-to-leaf order of the dependency tree.
- All plugins' initialize functions are called in root-to-leaf order of the dependency tree. This is a good time to create objects needed by other plugins and register them via appropriate core functions or, if a weak dependency is neceessary to be implemented, to put them into the global object pool.
- All plugins' extensionsInitialized functions are called in leaf-to-root order of the dependency tree. At this point, plugins can be sure that all plugins that depend on this plugin have been initialized completely and objects these plugins wish to share have been registered or are available in the global object pool.
If library loading or initialization of a plugin fails, all plugins that depend on that plugin also fail.