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  ·  Tous les espaces de nom  ·  Toutes les classes  ·  Classes principales  ·  Annotées  ·  Classes groupées  ·  Modules  ·  Fonctions  · 

QExtensionFactory Class Reference
[QtDesigner module]

The QExtensionFactory class allows you to create a factory that is able to make instances of custom extensions in Qt Designer. More...

 #include <QExtensionFactory>

Inherits QObject and QAbstractExtensionFactory.

Public Functions

Protected Functions

  • virtual QObject * createExtension ( QObject * object, const QString & iid, QObject * parent ) const
  • 7 protected functions inherited from QObject

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

Detailed Description

The QExtensionFactory class allows you to create a factory that is able to make instances of custom extensions in Qt Designer.

In Qt Designer the extensions are not created until they are required. For that reason, when implementing a custom 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 QExtensionManager class provides extension management facilities for Qt Designer. 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 a 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 multi page container, a member sheet, a property sheet or a task menu.

You can either create a new QExtensionFactory and reimplement the QExtensionFactory::createExtension() function. For example:

 QObject *ANewExtensionFactory::createExtension(QObject *object,
         const QString &iid, QObject *parent) const
 {
     if (iid != Q_TYPEID(QDesignerContainerExtension))
         return 0;

     if (MyCustomWidget *widget = qobject_cast<MyCustomWidget*>
            (object))
         return new MyContainerExtension(widget, parent);

     return 0;
 }

Or you can use an existing factory, expanding the QExtensionFactory::createExtension() function to make the factory able to create your extension as well. For example:

 QObject *AGeneralExtensionFactory::createExtension(QObject *object,
         const QString &iid, QObject *parent) const
 {
     MyCustomWidget *widget = qobject_cast<MyCustomWidget*>(object);

     if (widget && (iid == Q_TYPEID(QDesignerTaskMenuExtension))) {
         return new MyTaskMenuExtension(widget, parent);

     } else if (widget && (iid == Q_TYPEID(QDesignerContainerExtension))) {
         return new MyContainerExtension(widget, parent);

     } else {
         return 0;
     }
 }

For a complete example using the QExtensionFactory 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 QExtensionManager and QAbstractExtensionFactory.


Member Function Documentation

QExtensionFactory::QExtensionFactory ( QExtensionManager * parent = 0 )

Constructs an extension factory with the given parent.

QObject * QExtensionFactory::createExtension ( QObject * object, const QString & iid, QObject * parent ) const   [virtual protected]

Creates an extension specified by iid for the given object. The extension object is created as a child of the specified parent.

See also extension().

QObject * QExtensionFactory::extension ( QObject * object, const QString & iid ) const   [virtual]

Returns the extension specified by iid for the given object.

Reimplemented from QAbstractExtensionFactory.

See also createExtension().

QExtensionManager * QExtensionFactory::extensionManager () const

Returns the extension manager for the extension factory.

Publicité

Best Of

Actualités les plus lues

Semaine
Mois
Année

Le Qt Developer Network au hasard

Logo

Utiliser QML et QtWebKit avec PySide

Le Qt Developer Network est un réseau de développeurs Qt anglophone, où ils peuvent partager leur expérience sur le framework. 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.3
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