summaryrefslogtreecommitdiff
path: root/examples/designer/doc/src/customwidgetplugin.qdoc
diff options
context:
space:
mode:
Diffstat (limited to 'examples/designer/doc/src/customwidgetplugin.qdoc')
-rw-r--r--examples/designer/doc/src/customwidgetplugin.qdoc88
1 files changed, 50 insertions, 38 deletions
diff --git a/examples/designer/doc/src/customwidgetplugin.qdoc b/examples/designer/doc/src/customwidgetplugin.qdoc
index b7ab1e8a0..3ce9285c8 100644
--- a/examples/designer/doc/src/customwidgetplugin.qdoc
+++ b/examples/designer/doc/src/customwidgetplugin.qdoc
@@ -21,59 +21,68 @@
example, we reuse the \l{widgets/analogclock}{Analog Clock example} for
convenience.
- Since custom widgets plugins rely on components supplied with \QD, the
- project file that we use needs to contain information about \QD's
- library components:
+ \section1 Project files
- \snippet customwidgetplugin/customwidgetplugin.pro 2
- \snippet customwidgetplugin/customwidgetplugin.pro 0
+ \section2 CMake
- The \c TEMPLATE variable's value makes \c qmake create the custom
- widget as a library. Later, we will ensure that the widget will be
- recognized as a plugin by Qt by using the Q_PLUGIN_METADATA() macro
- to export the relevant widget information.
+ The project files need to state that a plugin linking
+ to the \QD libraries is to be built:
+ \snippet customwidgetplugin/CMakeLists.txt 0
+ \codeline
+ \snippet customwidgetplugin/CMakeLists.txt 2
- The \c CONFIG variable is set to \c plugin, which ensures that \c qmake
- considers the custom widget a plugin library.
+ The link libraries list specifies \c Qt::UiPlugin. This indicates that
+ the plugin uses the abstract interfaces QDesignerCustomWidgetInterface
+ and QDesignerCustomWidgetCollectionInterface only and has no linkage
+ to the \QD libraries. When accessing other interfaces of \QD that have
+ linkage, \c Designer should be used instead; this ensures that the plugin
+ dynamically links to the \QD libraries and has a run-time dependency on
+ them.
- The \c QT variable contains the keyword \c uiplugin. This plugin type
- provides a factory function for custom widget creation by implementing
- the abstract interfaces QDesignerCustomWidgetInterface or
- QDesignerCustomWidgetCollectionInterface, suitable for use with
- QUiLoader. It does not have a dependency on the \QD libraries.
- Plugins accessing other interfaces of \QD to implement container extensions
- or other \QD specific functionality follow different rules and are covered
- by other examples.
+ The following example shows how to add the header and source files of the
+ widget:
- The header and source files for the widget are declared in the usual way,
- and we provide an implementation of the plugin interface so that \QD can
- use the custom widget:
+ \snippet customwidgetplugin/CMakeLists.txt 1
- \snippet customwidgetplugin/customwidgetplugin.pro 3
+ We provide an implementation of the plugin interface so that \QD
+ can use the custom widget.
It is also important to ensure that the plugin is installed in a
location that is searched by \QD. We do this by specifying a
target path for the project and adding it to the list of items to
install:
- \snippet doc/snippets/doc_src_examples_customwidgetplugin.pro 0
+ \snippet customwidgetplugin/CMakeLists.txt 3
+ \snippet customwidgetplugin/CMakeLists.txt 4
+
+ The custom widget is created as a library. It will be
+ installed alongside the other \QD plugins when the project is
+ installed (using \c{ninja install} or an equivalent installation
+ procedure).
+
+ For more information about plugins, see the
+ \l {How to Create Qt Plugins} documentation.
+
+ \section2 qmake
+
+ The following example shows how to link a plugin to the \QD libraries:
- The custom widget is created as a library, and will be installed
- alongside the other \QD plugins when the project is installed
- (using \c{make install} or an equivalent installation procedure).
- Later, we will ensure that it is recognized as a plugin by \QD by
- using the Q_PLUGIN_METADATA() macro to export the relevant widget
- information.
+ \snippet customwidgetplugin/customwidgetplugin.pro 0
+ \codeline
+ \snippet customwidgetplugin/customwidgetplugin.pro 1
+
+ The \c QT variable contains the keyword \c uiplugin, which is
+ the equivalent of the \c Qt::UiPlugin library.
- Note that if you want the plugins to appear in a Visual Studio
- integration, the plugins must be built in release mode and their
- libraries must be copied into the plugin directory in the install
- path of the integration (for an example, see \c {C:/program
- files/trolltech as/visual studio integration/plugins}).
+ The following example shows how to add the header and source files of the
+ widget:
+
+ \snippet customwidgetplugin/customwidgetplugin.pro 2
- For more information about plugins, see the \l {How to
- Create Qt Plugins} documentation.
+ The following example shows how to install a plugin to the \QD's plugin path:
+
+ \snippet customwidgetplugin/customwidgetplugin.pro 3
\section1 AnalogClock Class Definition and Implementation
@@ -88,7 +97,10 @@
The \c AnalogClock class is exposed to \QD through the \c
AnalogClockPlugin class. This class inherits from both QObject and
the QDesignerCustomWidgetInterface class, and implements an
- interface defined by QDesignerCustomWidgetInterface:
+ interface defined by QDesignerCustomWidgetInterface.
+
+ To ensure that Qt recognizes the widget as a plugin, export relevant
+ information about the widget by adding the \c Q_PLUGIN_METADATA() macro:
\snippet customwidgetplugin/customwidgetplugin.h 0