Qt:Документация 4.3.2/qextensionmanager

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

Перейти к: навигация, поиск
40px Внимание: Актуальная версия перевода документации находится здесь

__NOTOC__

Image:qt-logo.png

Главная · Все классы · Основные классы · Классы по группам · Модули · Функции

Image:trolltech-logo.png

Содержание

[править] QExtensionManager Class Reference
[модуль QtDesigner ]

The QExtensionManager class provides extension management facilities for Qt Designer. More...

 #include <QExtensionManager>

Inherits QObject and QAbstractExtensionManager.

[править] Открытые функции

  • 29 открытых функций унаследованных от QObject
  • 3 открытых функций унаследованных от QAbstractExtensionManager

[править] Связанные не-члены

  • T qt_extension ( QAbstractExtensionManager * manager, QObject * object )

[править] Макросы

[править] Дополнительные унаследованные члены

  • 1 свойство унаследованное от QObject
  • 1 открытый слот унаследованный от QObject
  • 1 сигнал унаследованный от QObject
  • 5 статических открытых члена унаследованных от QObject
  • 7 защищенных функций унаследованных от QObject

[править] Подробное описание

The QExtensionManager class provides extension management facilities for Qt Designer.

In Qt Designer the extensions are not created until they are required. For that reason, when implementing an extension, you must also create a QExtensionFactory, i.e a class that is able to make an instance of your extension, and register it using Qt Designer's extension manager.

The registration of an extension factory is typically made in the QDesignerCustomWidgetInterface::initialize() function:

 void MyPlugin::initialize(QDesignerFormEditorInterface *formEditor)
 {
     if (initialized)
         return;
 
     QExtensionManager *manager = formEditor->extensionManager();
     Q_ASSERT(manager != 0);
 
     manager->registerExtensions(new MyExtensionFactory(manager),
                                 Q_TYPEID(QDesignerTaskMenuExtension));
 
     initialized = true;
 }

The QExtensionManager is not intended to be instantiated directly. You can retrieve an interface to Qt Designers extension manager using the QDesignerFormEditorInterface::extensionManager() function. A pointer to Qt Designers current QDesignerFormEditorInterface object (formEditor in the example above) is provided by the QDesignerCustomWidgetInterface::initialize() function's parameter. When implementing a custom widget plugin, you must subclass the QDesignerCustomWidgetInterface to expose your plugin to Qt Designer.

Then, when an extension is required, Qt Designer's extension manager will run through all its registered factories calling QExtensionFactory::createExtension() for each until the first one that is able to create the requested extension for the selected object, is found. This factory will then make an instance of the extension.

There are four available types of extensions in Qt Designer: QDesignerContainerExtension , QDesignerMemberSheetExtension, QDesignerPropertySheetExtension and QDesignerTaskMenuExtension. Qt Designer's behavior is the same whether the requested extension is associated with a container, a member sheet, a property sheet or a task menu.

For a complete example using the QExtensionManager class, see the Task Menu Extension example. The example shows how to create a custom widget plugin for Qt Designer, and how to to use the QDesignerTaskMenuExtension class to add custom items to Qt Designer's task menu.

See also QExtensionFactory and QAbstractExtensionManager.


[править] Описание функций-членов

[править]
QExtensionManager::QExtensionManager ( QObject * parent = 0 )

Constructs an extension manager with the given parent.

[править]
QExtensionManager::~QExtensionManager ()

Destroys the extension manager

[править]
QObject * QExtensionManager::extension ( QObject * object, const QString & iid ) const [virtual]

Returns the extension specified by iid, for the given object.

Reimplemented from QAbstractExtensionManager.

[править]
void QExtensionManager::registerExtensions ( QAbstractExtensionFactory * factory, const QString & iid = QString() ) [virtual]

Register the extension specified by the given factory and extension identifier iid.

Reimplemented from QAbstractExtensionManager.

[править]
void QExtensionManager::unregisterExtensions ( QAbstractExtensionFactory * factory, const QString & iid = QString() ) [virtual]

Unregister the extension specified by the given factory and extension identifier iid.

Reimplemented from QAbstractExtensionManager.


[править] Связанные не-члены

[править]
T qt_extension ( QAbstractExtensionManager * manager, QObject * object )

Returns the extension of the given object cast to type T if the object is of type T (or of a subclass); otherwise returns 0. The extension is retrieved using the given extension manager.

 QDesignerPropertySheetExtension *propertySheet;
 QExtensionManager manager = formEditor->extensionManager();
 
 propertySheet = qt_extension<QDesignerPropertySheetExtension*>(manager, widget);
 
 if(propertySheet) {...}

When implementing a custom widget plugin, a pointer to Qt Designer's current QDesignerFormEditorInterface object (formEditor) is provided by the QDesignerCustomWidgetInterface::initialize() function's parameter.

If the widget in the example above doesn't have a defined QDesignerPropertySheetExtension, propertySheet will be a null pointer.


[править] Macro Documentation

[править]
Q_DECLARE_EXTENSION_INTERFACE ( ExtensionName, Identifier )

Associates the given Identifier (a string literal) to the extension class called ExtensionName. The Identifier must be unique. For example:

 Q_DECLARE_EXTENSION_INTERFACE(MyExtension, "com.mycompany.myproduct.myextension")

Using the company and product names is a good way to ensure uniqueness of the identifier.

When implementing a custom extension class, you must use Q_DECLARE_EXTENSION_INTERFACE() to enable usage of the qt_extension() function. The macro is normally located right after the class definition for ExtensionName, in the associated header file.

See also Q_DECLARE_INTERFACE().


Copyright © 2007 Trolltech Trademarks
Qt 4.3.2