Viadeo Twitter Google Bookmarks ! Facebook Digg del.icio.us MySpace Yahoo MyWeb Blinklist Netvouz Reddit Simpy StumbleUpon Bookmarks Windows Live Favorites 
Logo Documentation Qt ·  Page d'accueil  ·  Toutes les classes  ·  Toutes les fonctions  ·  Vues d'ensemble  · 

QExtensionManager Class Reference

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

 #include <QExtensionManager>

Inherits: QObject and QAbstractExtensionManager.

Public Functions

QExtensionManager ( QObject * parent = 0 )
~QExtensionManager ()

Reimplemented Public Functions

virtual QObject * extension ( QObject * object, const QString & iid ) const
virtual void registerExtensions ( QAbstractExtensionFactory * factory, const QString & iid = QString() )
virtual void unregisterExtensions ( QAbstractExtensionFactory * factory, const QString & iid = QString() )

Related Non-Members

T qt_extension ( QAbstractExtensionManager * manager, QObject * object )

Macros

Q_DECLARE_EXTENSION_INTERFACE ( ExtensionName, Identifier )

Additional Inherited Members

  • 1 property inherited from QObject
  • 1 public slot inherited from QObject
  • 1 signal inherited from QObject
  • 5 static public members inherited from QObject
  • 7 protected functions inherited from QObject

Detailed Description

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 Designer's extension manager using the QDesignerFormEditorInterface::extensionManager() function. A pointer to Qt Designer's 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.

Member Function Documentation

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]

Reimplemented from QAbstractExtensionManager::extension().

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

void QExtensionManager::registerExtensions ( QAbstractExtensionFactory * factory, const QString & iid = QString() ) [virtual]

Reimplemented from QAbstractExtensionManager::registerExtensions().

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

void QExtensionManager::unregisterExtensions ( QAbstractExtensionFactory * factory, const QString & iid = QString() ) [virtual]

Reimplemented from QAbstractExtensionManager::unregisterExtensions().

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

Related Non-Members

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().

Publicit�

Best Of

Actualit�s les plus lues

Semaine
Mois
Ann�e
  1. Microsoft ouvre aux autres compilateurs C++ AMP, la sp�cification pour la conception d'applications parall�les C++ utilisant le GPU 22
  2. Les d�veloppeurs ignorent-ils trop les failles d�couvertes dans leur code ? Prenez-vous en compte les remarques des autres ? 17
  3. RIM : � 13 % des d�veloppeurs ont gagn� plus de 100 000 $ sur l'AppWord �, Qt et open-source au menu du BlackBerry DevCon Europe 0
  4. BlackBerry 10 : premi�res images du prochain OS de RIM qui devrait int�grer des widgets et des tuiles inspir�es de Windows Phone 0
  5. Adieu qmake, bienvenue qbs : Qt Building Suite, un outil d�claratif et extensible pour la compilation de projets Qt 17
  6. Quelles nouveaut�s de C++11 Visual C++ doit-il rapidement int�grer ? Donnez-nous votre avis 10
  7. La rubrique Qt a besoin de vous ! 1
Page suivante

Le Qt Quarterly au hasard

Logo

Des apparences personnalis�es utilisant les feuilles de style

Qt Quarterly est la revue trimestrielle propos�e par Nokia et � destination des d�veloppeurs Qt. Ces articles d'une grande qualit� technique sont r�dig�s par des experts Qt. Lire l'article.

Communaut�

Ressources

Liens utiles

Contact

  • Vous souhaitez rejoindre la r�daction ou proposer un tutoriel, une traduction, une question... ? Postez dans le forum Contribuez ou contactez-nous par MP ou par email (voir en bas de page).

Qt dans le magazine

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.7
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 !
 
 
 
 
Partenaires

H�bergement Web