org.kde.koala
public class KLibFactory extends QObject
K_EXPORT_COMPONENT_FACTORY( libkspread, KSpreadFactory )The first macro argument is the name of your library, the second specifies the name of your factory. NOTE: you probably want to use KGenericFactory
s_global = new KInstance( "kspread" );This KInstance is comparable to KGlobal used by normal applications. It allows you to find resource files (images, XML, sound etc.) belonging to the library. If you want to load a library, use KLibLoader. You can query KLibLoader directly for a pointer to the libraries factory by using the KLibLoader.factory() function. The KLibFactory is used to create the components, the library has to offer. The factory of KSpread for example will create instances of KSpreadDoc, while the Konqueror factory will create KonqView widgets. All objects created by the factory must be derived from QObject, since QObject offers type safe casting. KLibFactory is an abstract class. Reimplement the createObject() method to give it functionality. See KLibFactorySignals for signals emitted by KLibFactory
UNKNOWN: If you develop a library that is to be loaded dynamically at runtime, then you should return a pointer to your factory.
Constructor Summary | |
---|---|
protected | KLibFactory(Class dummy) |
Method Summary | |
---|---|
String | className() |
QObject | create(QObject parent, String name, String classname, String[] args)
Creates a new object. |
QObject | create(QObject parent, String name, String classname) |
QObject | create(QObject parent, String name) |
QObject | create(QObject parent) |
QObject | create() |
QMetaObject | metaObject() |
classname.
For example a koffice
library may usually return a pointer to KoDocument. But
if asked for a "QWidget", it could create a wrapper widget,
that encapsulates the Koffice specific features.
create() automatically emits a signal objectCreated to tell
the library about its newly created object. This is very
important for reference counting, and allows unloading the
library automatically once all its objects have been destroyed.Parameters: parent the parent of the QObject, 0 for no parent name the name of the QObject, 0 for no name classname the name of the class args a list of arguments
UNKNOWN: Creates a new object.