• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdelibs API Reference
  • 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 58 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 80 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 205 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 126 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 147 of file componentfactory.h.

This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:25:36 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KParts

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

kdelibs API Reference

Skip menu "kdelibs API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • 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

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal