Home · All Namespaces · All Classes · Grouped Classes · Modules · Functions |
The QPluginManager class simplifies plug-in loading and allows plugins to be enabled/disabled. More...
#include <QPluginManager>
Inherits QObject.
The QPluginManager class simplifies plug-in loading and allows plugins to be enabled/disabled.
The most common use is to iterate over the list of plugins and load each one as follows:
QPluginManager pluginManager( "Effects" ); QStringList list = pluginManager.list(); QStringList::Iterator it; QList<EffectsInterface*> effectList; for ( it = list.begin(); it != list.end(); ++it ) { QObject *instance = pluginManager->instance(*it); EffectsInterface *iface = 0; iface = qobject_cast<EffectsInterface*>(instance); if (iface) { effectList.append( iface ); } }
The list() function returns a list of plugins, using the filenames of the plugins in the plugin directory. This does not require any plugins to be loaded, so it is very lightweight.
In order to load a plugin, call the instance() function with the name of the plugin to load. qobject_cast() may then be used to query for the desired interface.
If the application loading a plugin crashes during while loading the plugin, the plugin will be disabled. This prevents a plugin from permanently rendering an application unusable. Disabled plugins can be queried using disabledList() and reenabled using setEnabled().
Creates a QPluginManager for plugins of type with the given parent.
The plugins must be installed in the [qt_prefix]/plugins/type directory.
Destroys the QPluginManager and releases any resources allocated by the PluginManager.
Releases all resources allocated by the QPluginManager
Returns the list of plugins that have been disabled.
Returns true if Qt Extended is currently in Safe Mode. In safe mode list() will return an empty list and no plugins should be loaded. This is to allow misbehaving plugins to be disabled.
Load the plug-in specified by name.
Returns the plugin interface if found, otherwise 0.
QObject *instance = pluginManager->instance("name");
if (instance) {
EffectsInterface *iface = 0;
iface = qobject_cast<EffectsInterface*>(instance);
if (iface) {
// We have an instance of the desired type.
}
}
If an instance is no longer required and resources need to be released, simply delete the returned instance.
Returns true if the plug-in name is enabled.
Returns the list of plugins that are available.
The plugin list is derived from the filenames of the plugins and does not force any plugins to be loaded.
Enables or disables plug-in name depending on the value of enabled. A disabled plug-in can still be loaded, but it will not be returned by list().
See also isEnabled().
Copyright © 2009 Trolltech | Trademarks | Qt Extended 4.4.3 |