Logo Search packages:      
Sourcecode: qt4-x11 version File versions

QExtensionFactory Class Reference

Inheritance diagram for QExtensionFactory:

QObject QAbstractExtensionFactory

List of all members.


Detailed Description

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

QtDesigner

In 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 's {QExtensionManager}{extension manager}.

The QExtensionManager class provides extension management facilities for Qt Designer. When an extension is required, Qt Designer's {QExtensionManager}{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 {designer/taskmenuextension}{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, QAbstractExtensionFactory

Definition at line 38 of file default_extensionfactory.h.


Public Slots

void deleteLater ()

Signals

void destroyed (QObject *=0)

Public Member Functions

bool blockSignals (bool b)
const QObjectListchildren () const
bool connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const
bool disconnect (const QObject *receiver, const char *member=0)
bool disconnect (const char *signal=0, const QObject *receiver=0, const char *member=0)
void dumpObjectInfo ()
void dumpObjectTree ()
QList< QByteArraydynamicPropertyNames () const
virtual bool event (QEvent *)
virtual bool eventFilter (QObject *, QEvent *)
virtual QObjectextension (QObject *object, const QString &iid) const
QExtensionManagerextensionManager () const
template<typename T>
findChild (const QString &name=QString()) const
template<typename T>
QList< T > findChildren (const QRegExp &re) const
template<typename T>
QList< T > findChildren (const QString &name=QString()) const
bool inherits (const char *classname) const
void installEventFilter (QObject *)
bool isWidgetType () const
void killTimer (int id)
void moveToThread (QThread *thread)
QString objectName () const
QObjectparent () const
QVariant property (const char *name) const
 QExtensionFactory (QExtensionManager *parent=0)
void removeEventFilter (QObject *)
void setObjectName (const QString &name)
void setParent (QObject *)
bool setProperty (const char *name, const QVariant &value)
void setUserData (uint id, QObjectUserData *data)
bool signalsBlocked () const
int startTimer (int interval)
QThreadthread () const
QObjectUserData * userData (uint id) const

Static Public Member Functions

static bool connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
static bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member)
static uint registerUserData ()

Protected Member Functions

virtual void childEvent (QChildEvent *)
virtual void connectNotify (const char *signal)
virtual QObjectcreateExtension (QObject *object, const QString &iid, QObject *parent) const
virtual void customEvent (QEvent *)
virtual void disconnectNotify (const char *signal)
int receivers (const char *signal) const
QObjectsender () const
virtual void timerEvent (QTimerEvent *)

Protected Attributes

QObjectData * d_ptr

Static Protected Attributes

static const QMetaObject staticQtMetaObject

Properties

QString objectName
 the name of this object

Private Slots

void objectDestroyed (QObject *object)

Private Attributes

QHash< QObject *, bool > m_extended
QMap< QPair< QString, QObject * >
, QObject * > 
m_extensions

Friends

class QApplication
class QApplicationPrivate
class QCoreApplication
class QCoreApplicationPrivate
struct QMetaObject
class QThreadData
class QWidget

Related Functions

(Note that these are not member functions.)

qFindChild (const QObject *obj, const QString &name=QString(), T dummy=0)
qFindChild (const QObject *obj, const QString &name)
QList< T > qFindChildren (const QObject *obj, const QString &name=QString(), T dummy=0)
QList< T > qFindChildren (const QObject *obj, const QRegExp &regExp)
QList< T > qFindChildren (const QObject *obj, const QString &name)
T * qobject_cast (QObject *object)
 QObjectList
void * qt_find_obj_child (QObject *parent, const char *type, const QString &name)

The documentation for this class was generated from the following files:

Generated by  Doxygen 1.6.0   Back to index