diff options
Diffstat (limited to 'examples/designer/doc/src/worldtimeclockplugin.qdoc')
-rw-r--r-- | examples/designer/doc/src/worldtimeclockplugin.qdoc | 94 |
1 files changed, 56 insertions, 38 deletions
diff --git a/examples/designer/doc/src/worldtimeclockplugin.qdoc b/examples/designer/doc/src/worldtimeclockplugin.qdoc index 81bb90126..25198f261 100644 --- a/examples/designer/doc/src/worldtimeclockplugin.qdoc +++ b/examples/designer/doc/src/worldtimeclockplugin.qdoc @@ -79,7 +79,10 @@ {customwidgetplugin}{Custom Widget Plugin} example's plugin class which is explained in detail. The only part of the class definition that is specific to this particular custom widget - is the class name: + is the class name. + + 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 worldtimeclockplugin/worldtimeclockplugin.h 0 @@ -113,52 +116,67 @@ Without this macro, there is no way for Qt Designer to use the widget. - \section1 The Project File: worldtimeclockplugin.pro - - The project file for custom widget plugins needs some additional - information to ensure that they will work as expected within \QD: + \section1 Project files + \section2 CMake - \snippet worldtimeclockplugin/worldtimeclockplugin.pro 0 - \snippet worldtimeclockplugin/worldtimeclockplugin.pro 1 + The project files need to state that a plugin linking + to the \QD libraries is to be built: - The \c TEMPLATE variable's value in conjunction with the keyword - \c plugin in the \c CONFIG variable make \c qmake create the custom - widget as a plugin library. + \snippet worldtimeclockplugin/CMakeLists.txt 0 + \codeline + \snippet worldtimeclockplugin/CMakeLists.txt 2 - 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 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 header and source files for the widget are declared in the - usual way, and in addition we provide an implementation of the - plugin interface so that \QD can use the custom widget. + usual way: - \snippet worldtimeclockplugin/worldtimeclockplugin.pro 2 + \snippet worldtimeclockplugin/CMakeLists.txt 1 + + We provide an implementation of the plugin interface so that \QD + can use the custom widget. In this particular example we also + provide implementations of the container extension interface and + the extension factory. + + It is 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 worldtimeclockplugin/CMakeLists.txt 3 + \snippet worldtimeclockplugin/CMakeLists.txt 4 - It is 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: + 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). - \snippet doc/snippets/doc_src_examples_worldtimeclockplugin.pro 0 + For more information about plugins, see the + \l {How to Create Qt Plugins} documentation. - 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. + \section2 qmake + + The following example shows how to link a plugin to the \QD libraries: + + \snippet worldtimeclockplugin/worldtimeclockplugin.pro 0 + \codeline + \snippet worldtimeclockplugin/worldtimeclockplugin.pro 1 + + The \c QT variable contains the keyword \c uiplugin, which is + the equivalent of the \c Qt::UiPlugin library. + + The following example shows how to add the header and source files of the + widget: + + \snippet worldtimeclockplugin/worldtimeclockplugin.pro 2 - 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 install a plugin to the \QD's plugin path: - For more information about plugins, see the \l {How to Create Qt - Plugins} document. + \snippet worldtimeclockplugin/worldtimeclockplugin.pro 3 */ |