Doc: Updated outdated docs to use new macro
Change-Id: I9a3528112fba1db988592d9f4f470ec678e81e1a Reviewed-by: Jerome Pasion <jerome.pasion@digia.com>
This commit is contained in:
parent
db4aa4d1d5
commit
ed043bf24a
@ -287,7 +287,7 @@
|
|||||||
\snippet tools/plugandpaint/main.cpp 0
|
\snippet tools/plugandpaint/main.cpp 0
|
||||||
|
|
||||||
The argument to Q_IMPORT_PLUGIN() is the plugin's name, as
|
The argument to Q_IMPORT_PLUGIN() is the plugin's name, as
|
||||||
specified with Q_EXPORT_PLUGIN2() in the \l{Exporting the
|
specified with Q_PLUGIN_METADATA() in the \l{Exporting the
|
||||||
Plugin}{plugin}.
|
Plugin}{plugin}.
|
||||||
|
|
||||||
In the \c .pro file, we need to specify the static library.
|
In the \c .pro file, we need to specify the static library.
|
||||||
@ -324,7 +324,7 @@
|
|||||||
\list 1
|
\list 1
|
||||||
\li Declare a plugin class.
|
\li Declare a plugin class.
|
||||||
\li Implement the interfaces provided by the plugin.
|
\li Implement the interfaces provided by the plugin.
|
||||||
\li Export the plugin using the Q_EXPORT_PLUGIN2() macro.
|
\li Export the plugin using the Q_PLUGIN_METADATA() macro.
|
||||||
\li Build the plugin using an adequate \c .pro file.
|
\li Build the plugin using an adequate \c .pro file.
|
||||||
\endlist
|
\endlist
|
||||||
|
|
||||||
@ -346,6 +346,8 @@
|
|||||||
interfaces. Without the \c Q_INTERFACES() macro, we couldn't use
|
interfaces. Without the \c Q_INTERFACES() macro, we couldn't use
|
||||||
\l qobject_cast() in the \l{plugandpaint}{Plug & Paint}
|
\l qobject_cast() in the \l{plugandpaint}{Plug & Paint}
|
||||||
application to detect interfaces.
|
application to detect interfaces.
|
||||||
|
For an explanation for the \c Q_PLUGIN_METADATA() macro see
|
||||||
|
\l {Exporting the Plugin}.
|
||||||
|
|
||||||
\snippet tools/plugandpaintplugins/basictools/basictoolsplugin.h 2
|
\snippet tools/plugandpaintplugins/basictools/basictoolsplugin.h 2
|
||||||
|
|
||||||
@ -440,15 +442,20 @@
|
|||||||
|
|
||||||
\section1 Exporting the Plugin
|
\section1 Exporting the Plugin
|
||||||
|
|
||||||
Whereas applications have a \c main() function as their entry
|
To finally export your plugin you just have to add the
|
||||||
point, plugins need to contain exactly one occurrence of the
|
\c Q_PLUGIN_METADATA() macro right next to the \c Q_OBJECT() macro
|
||||||
Q_EXPORT_PLUGIN2() macro to specify which class provides the
|
into the header file of the plugin.
|
||||||
plugin:
|
It must contain the plugins IID and optionally a filename pointing
|
||||||
|
to a json file containing the metadata for the plugin.
|
||||||
|
|
||||||
\snippet tools/plugandpaintplugins/basictools/basictoolsplugin.cpp 9
|
\snippet tools/plugandpaintplugins/basictools/basictoolsplugin.h 4
|
||||||
|
|
||||||
This line may appear in any \c .cpp file that is part of the
|
Within this example the json file does not need to export any metadata,
|
||||||
plugin's source code.
|
so it just contains an empty json object.
|
||||||
|
|
||||||
|
\code
|
||||||
|
{}
|
||||||
|
\endcode
|
||||||
|
|
||||||
\section1 The .pro File
|
\section1 The .pro File
|
||||||
|
|
||||||
|
@ -58,7 +58,9 @@ class BasicToolsPlugin : public QObject,
|
|||||||
public FilterInterface
|
public FilterInterface
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
//! [4]
|
||||||
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.Examples.PlugAndPaint.BrushInterface" FILE "basictools.json")
|
Q_PLUGIN_METADATA(IID "org.qt-project.Qt.Examples.PlugAndPaint.BrushInterface" FILE "basictools.json")
|
||||||
|
//! [4]
|
||||||
Q_INTERFACES(BrushInterface ShapeInterface FilterInterface)
|
Q_INTERFACES(BrushInterface ShapeInterface FilterInterface)
|
||||||
//! [0]
|
//! [0]
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user