• Skip to content
  • Skip to link menu
KDE 4.6 API Reference
  • KDE API Reference
  • kdelibs
  • KDE Home
  • Contact Us
 

KParts

  • KParts
  • ComponentFactory
Functions

KParts::ComponentFactory Namespace Reference

Functions

template<class T >
T * createPartInstanceFromFactory (KParts::Factory *factory, QWidget *parentWidget=0, QObject *parent=0, const QStringList &args=QStringList())
template<class T >
T * createPartInstanceFromLibrary (const char *libraryName, QWidget *parentWidget=0, QObject *parent=0, const QStringList &args=QStringList(), int *error=0)
template<class T >
T * createPartInstanceFromQuery (const QString &mimeType, const QString &constraint, QWidget *parentWidget=0, QObject *parent=0, const QStringList &args=QStringList(), int *error=0)
template<class T >
T * createPartInstanceFromService (const KService::Ptr &service, QWidget *parentWidget=0, QObject *parent=0, const QStringList &args=QStringList(), int *error=0)
template<class T , class ServiceIterator >
T * createPartInstanceFromServices (ServiceIterator begin, ServiceIterator end, QWidget *parentWidget=0, QObject *parent=0, const QStringList &args=QStringList(), int *error=0)

Function Documentation

template<class T >
T* KParts::ComponentFactory::createPartInstanceFromFactory ( KParts::Factory *  factory,
QWidget *  parentWidget = 0,
QObject *  parent = 0,
const QStringList &  args = QStringList() 
)

This template function allows to ask the given kparts factory to create an instance of the given template type.

Example of usage:

     KViewPart *doc = KParts::ComponentFactory::createPartInstanceFromFactory&lt;KViewPart&gt;( factory, parent );
Deprecated:
use KPluginFactory::create instead
Parameters:
factoryThe factory to ask for the creation of the component
parentWidgetthe parent widget for the part
parentThe parent object (see QObject constructor)
argsA list of string arguments, passed to the factory and possibly to the component (see KLibFactory)
Returns:
A pointer to the newly created object or a null pointer if the factory was unable to create an object of the given type.

Definition at line 56 of file componentfactory.h.

template<class T >
T* KParts::ComponentFactory::createPartInstanceFromLibrary ( const char *  libraryName,
QWidget *  parentWidget = 0,
QObject *  parent = 0,
const QStringList &  args = QStringList(),
int *  error = 0 
)

Definition at line 78 of file componentfactory.h.

template<class T >
T* KParts::ComponentFactory::createPartInstanceFromQuery ( const QString &  mimeType,
const QString &  constraint,
QWidget *  parentWidget = 0,
QObject *  parent = 0,
const QStringList &  args = QStringList(),
int *  error = 0 
)

This method creates and returns a KParts part from a serviceType (e.g.

a mimetype).

You can use this method to create a generic viewer - that can display any kind of file, provided that there is a ReadOnlyPart installed for it - in 5 lines:

 // Given the following: KUrl url, QWidget* parentWidget and QObject* parentObject.
 QString mimetype = KMimeType::findByURL( url )->name();
 KParts::ReadOnlyPart* part = KParts::ComponentFactory::createPartInstanceFromQuery<KParts::ReadOnlyPart>( mimetype, QString(), parentWidget, parentObject );
 if ( part ) {
     part->openUrl( url );
     part->widget()->show();  // also insert the widget into a layout, or simply use a KVBox as parentWidget
 }
Deprecated:
use KMimeTypeTrader::createPartInstanceFromQuery instead
Parameters:
mimeTypethe mimetype which this part is associated with
constraintan optional constraint to pass to the trader (see KTrader)
parentWidgetthe parent widget, will be set as the parent of the part's widget
parentthe parent object for the part itself
argsA list of string arguments, passed to the factory and possibly to the component (see KLibFactory)
errorThe int passed here will receive an error code in case of errors. (See enum KLibLoader::ComponentLoadingError)
Returns:
A pointer to the newly created object or a null pointer if the factory was unable to create an object of the given type.

Definition at line 203 of file componentfactory.h.

template<class T >
T* KParts::ComponentFactory::createPartInstanceFromService ( const KService::Ptr &  service,
QWidget *  parentWidget = 0,
QObject *  parent = 0,
const QStringList &  args = QStringList(),
int *  error = 0 
)
Deprecated:
use KService::createInstance instead

Definition at line 124 of file componentfactory.h.

template<class T , class ServiceIterator >
T* KParts::ComponentFactory::createPartInstanceFromServices ( ServiceIterator  begin,
ServiceIterator  end,
QWidget *  parentWidget = 0,
QObject *  parent = 0,
const QStringList &  args = QStringList(),
int *  error = 0 
)

Definition at line 145 of file componentfactory.h.

KParts

Skip menu "KParts"
  • Main Page
  • Modules
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.7.3
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal