#include <kgenericfactory.h>
Inheritance diagram for KGenericFactory< KTypeList< Product, ProductListTail >, KTypeList< ParentType, ParentTypeListTail > >:

Protected Methods | |
| virtual QObject * | createObject (QObject *parent, const char *name, const char *className, const QStringList &args) |
Note that each class in the specified in the typelist template argument needs to provide a certain constructor:
MyClass( QObject *parent, const char *name, const QStringList &args ); MyWidget( QWidget *parent, const char *name, const QStringList &args); MyPart( QWidget *parentWidget, const char *widgetName, QObject *parent, const char *name, const QStringList &args ); In addition upon instantiation this template provides a central KInstance object for your component, accessible through the static instance() method. The instanceName argument of the KGenericFactory constructor is passed to the KInstance object.
The creation of the KInstance object can be customized by inheriting from this template class and re-implementing the virtual createInstance method. For example it could look like this:
KInstance *MyFactory::createInstance()
{
return new KInstance( myAboutData );
}
Example of usage of the whole template:
class MyPlugin : public KParts::Plugin
{
Q_ OBJECT
public:
MyPlugin( QObject *parent, const char *name,
const QStringList &args );
...
};
class MyDialogComponent : public KDialogBase
{
Q_ OBJECT
public:
MyDialogComponent( QWidget *parentWidget, const char *name,
const QStringList &args );
...
};
typedef K_TYPELIST_2( MyPlugin, MyDialogComponent ) Products;
K_EXPORT_COMPONENT_FACTORY( libmyplugin, KGenericFactory<Products> );
Definition at line 331 of file kgenericfactory.h.
|
||||||||||||||||||||||||
|
Creates a new object. The returned object has to be derived from the requested classname.
It is valid behavior to create different kinds of objects depending on the requested This function is called by create()
Implements KLibFactory. Definition at line 342 of file kgenericfactory.h. |
1.2.18