# kparts Library API Documentation

Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Source Files

# KParts::GenericFactory< T > Class Template Reference

A template for a KParts::Factory implementation. More...

`#include <genericfactory.h>`

List of all members.

## Public Member Functions

virtual KParts::Part * | createPartObject (QWidget *parentWidget, const char *widgetName, QObject *parent, const char *name, const char *className, const QStringList &args)

## Detailed Description

### template<class T>
class KParts::GenericFactory< T >

A template for a KParts::Factory implementation.

It implements the pure virtual createPartObject method by instantiating the template argument when requested through the className field. In addition it is a container for a part's KInstance object, by providing a static KInstance *instance() method.

The template argument has to inherit from KParts::Part and has to implement two methods: 1) There needs to be a public constructor with the following signature: MyPart( QWidget *parentWidget, const char *widgetName, QObject *parent, const char *name, const QStringList& args )

2) It needs to provide one static method to create a KAboutData object per request, holding information about the component's name, its authors, license, etc. The signature of that static method has to be KAboutData *createAboutData()

The template will take care of memory management of the KInstance and the KAboutData object.

For advanced use you can also inherit from the template and re-implement additionally the virtual KInstance *createInstance() method, for example in case you want to extend the paths of your instance's KStandardDirs object.

If a KParts::ReadOnlyPart is requested through this factory and the template argument implements a KParts::ReadWritePart then setReadWrite( false ) will automatically be called in createPartObject.

Use the factory through the K_EXPORT_COMPONENT_FACTORY macro, like that:

     typedef KParts::GenericFactory<YourKPart> YourKPartFactory;
     K_EXPORT_COMPONENT_FACTORY( yourlibrary, YourKPartFactory );

yourlibrary is the library name that you compiled your KPart into.

Definition at line 83 of file genericfactory.h.

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

- genericfactory.h

This file is part of the documentation for kdelibs Version 3.1.5.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Wed Jan 28 13:27:04 2004 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001