• Skip to content
  • Skip to link menu
KDE 4.3 API Reference
  • KDE API Reference
  • kdelibs
  • Sitemap
  • Contact Us
 

KParts

KParts::ComponentFactory

KParts::ComponentFactory Namespace Reference

Functions

template<class T >
KDE_DEPRECATED T * createPartInstanceFromFactory (KParts::Factory *factory, QWidget *parentWidget=0, QObject *parent=0, const QStringList &args=QStringList())
template<class T >
KDE_DEPRECATED 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 >
KDE_DEPRECATED T * createPartInstanceFromService (const KService::Ptr &service, QWidget *parentWidget=0, QObject *parent=0, const QStringList &args=QStringList(), int *error=0)
template<class T , class ServiceIterator >
KDE_DEPRECATED T * createPartInstanceFromServices (ServiceIterator begin, ServiceIterator end, QWidget *parentWidget=0, QObject *parent=0, const QStringList &args=QStringList(), int *error=0)

Function Documentation

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

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:
factory The factory to ask for the creation of the component
parentWidget the parent widget for the part
parent The parent object (see QObject constructor)
args A 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 53 of file componentfactory.h.

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

Definition at line 72 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 
) [inline]

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:
mimeType the mimetype which this part is associated with
constraint an optional constraint to pass to the trader (see KTrader)
parentWidget the parent widget, will be set as the parent of the part's widget
parent the parent object for the part itself
args A list of string arguments, passed to the factory and possibly to the component (see KLibFactory)
error The 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 191 of file componentfactory.h.

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

Definition at line 116 of file componentfactory.h.

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

Definition at line 135 of file componentfactory.h.

KParts

Skip menu "KParts"
  • Main Page
  • 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
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.6.1
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