KParts::PartLoader
Functions | |
template<class T > | |
static T * | createPartInstanceForMimeType (const QString &mimeType, QWidget *parentWidget=nullptr, QObject *parent=nullptr, QString *error=nullptr) |
template<typename T > | |
static KPluginFactory::Result< T > | instantiatePart (const KPluginMetaData &data, QWidget *parentWidget=nullptr, QObject *parent=nullptr, const QVariantList &args={}) |
template<class T > | |
static KPluginFactory::Result< T > | instantiatePartForMimeType (const QString &mimeType, QWidget *parentWidget=nullptr, QObject *parent=nullptr, const QVariantList &args={}) |
KPARTS_EXPORT QVector< KPluginMetaData > | partsForMimeType (const QString &mimeType) |
Detailed Description
Helper methods for locating and loading parts.
This is based upon KPluginFactory, but it takes care of querying by mimetype, sorting the available parts by builtin preference and by user preference.
- Since
- 5.69
Function Documentation
◆ createPartInstanceForMimeType()
|
static |
Use this method to create a KParts part.
It will try to create an object which inherits T
.
Example:
- Template Parameters
-
T The interface for which an object should be created. The object will inherit T
.
- Parameters
-
mimeType The mimetype for which we need a KParts. parentWidget The parent widget for the part's widget. parent The parent of the part. error Optional output parameter, it will be set to the error string, if any.
- Returns
- A pointer to the created object is returned, or
nullptr
if an error occurred.
- Since
- 5.69
Definition at line 200 of file partloader.h.
◆ instantiatePart()
|
static |
Attempts to create a KPart from the given metadata.
If there is no extra error handling needed the plugin can be directly accessed and checked if it is a nullptr
- Parameters
-
data KPluginMetaData from which the plugin should be loaded parentWidget The parent widget parent The parent object args A list of arguments to be passed to the part
- Returns
- Result object which contains the plugin instance and potentially error information
- Since
- 5.100
Definition at line 97 of file partloader.h.
◆ instantiatePartForMimeType()
|
static |
Use this method to create a KParts part.
It will try to create an object which inherits T
.
If there is no extra error handling needed the plugin can be directly accessed and checked if it is a nullptr
- Template Parameters
-
T The interface for which an object should be created. The object will inherit T
.
- Parameters
-
mimeType The mimetype for which we need a KParts. parentWidget The parent widget for the part's widget. parent The parent of the part.
- Returns
- Result object which contains the plugin instance and potentially error information
- Since
- 5.100
Definition at line 146 of file partloader.h.
◆ partsForMimeType()
QVector< KPluginMetaData > KParts::PartLoader::partsForMimeType | ( | const QString & | mimeType | ) |
Locate all available KParts for a mimetype.
- Returns
- a list of plugin metadata, sorted by preference. This takes care both of the builtin preference (set by developers) and of user preference (stored in mimeapps.list).
This uses KPluginMetaData::findPlugins, i.e. it requires the parts to provide the metadata as JSON embedded into the plugin. Until KF6, however, it also supports .desktop files as a fallback solution.
To load a part from one of the KPluginMetaData instances returned here, use instantiatePart()
- Since
- 5.69
Definition at line 78 of file partloader.cpp.
Documentation copyright © 1996-2023 The KDE developers.
Generated on Sat Sep 23 2023 03:49:41 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006
KDE's Doxygen guidelines are available online.