diff options
Diffstat (limited to 'examples/designer/doc/src/containerextension.qdoc')
-rw-r--r-- | examples/designer/doc/src/containerextension.qdoc | 83 |
1 files changed, 43 insertions, 40 deletions
diff --git a/examples/designer/doc/src/containerextension.qdoc b/examples/designer/doc/src/containerextension.qdoc index b20093a53..80c965a6f 100644 --- a/examples/designer/doc/src/containerextension.qdoc +++ b/examples/designer/doc/src/containerextension.qdoc @@ -59,41 +59,32 @@ extension. \endlist - The project file for custom widget plugins needs some additional + Project files for custom widget plugins need some additional information to ensure that they will work within \QD. For example, custom widget plugins rely on components supplied with \QD, and - this must be specified in the project file that we use. We will - first take a look at the plugin's project file. + this must be specified in the project files that we use. We will + first take a look at the plugin's project files. Then we will continue by reviewing the \c MultiPageWidgetPlugin class, and take a look at the \c MultiPageWidgetExtensionFactory and \c MultiPageWidgetContainerExtension classes. Finally, we will take a quick look at the \c MultiPageWidget class definition. - \section1 The Project File: containerextension.pro + \section1 Project files - The project file must contain some additional information to - ensure that the plugin will work as expected: + \section2 CMake - \snippet containerextension/containerextension.pro 0 - \snippet containerextension/containerextension.pro 1 - - 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: - The \c CONFIG variable is set to \c plugin, which ensures that \c qmake - considers the custom widget a plugin library. - - The \c QT variable contains the value \c designer. Since the plugin uses - components supplied with \QD that require linkage, this value ensures - that our plugin links against \QD's library (\c libQtDesigner.so). + \snippet containerextension/CMakeLists.txt 0 + \codeline + \snippet containerextension/CMakeLists.txt 2 - The header and source files for the widget are declared in the - usual way: + The following example shows how to add the header and source files of the + widget: - \snippet containerextension/containerextension.pro 2 + \snippet containerextension/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 @@ -105,21 +96,33 @@ target path for the project and adding it to the list of items to install: - \snippet doc/snippets/doc_src_examples_containerextension.pro 0 + \snippet containerextension/CMakeLists.txt 3 + \snippet containerextension/CMakeLists.txt 4 - The container extension is created as a library, and will be + The container extension is created as a library. It will be installed alongside the other \QD plugins when the project is - installed (using \c{make install} or an equivalent installation + installed (using \c{ninja install} or an equivalent installation procedure). - 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}). + 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: + + \snippet containerextension/containerextension.pro 0 + \codeline + \snippet containerextension/containerextension.pro 1 - For more information about plugins, see the \l {How to Create Qt - Plugins} documentation. + The following example shows how to add the header and source files of the + widget: + + \snippet containerextension/containerextension.pro 2 + + The following example shows how to install a plugin to the \QD's plugin path: + + \snippet containerextension/containerextension.pro 3 \section1 MultiPageWidgetPlugin Class Definition @@ -160,6 +163,14 @@ enables \QD to use qobject_cast() to query for supported interfaces using nothing but a QObject pointer. + 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 containerextension/multipagewidgetplugin.h 1 + + With this macro, \QD can access and construct the custom widget. + Without this macro, there is no way for \QD to use the widget. + \section1 MultiPageWidgetPlugin Class Implementation The MultiPageWidgetPlugin class implementation is in most parts @@ -310,14 +321,6 @@ page; any inital pages of a multi-page widget must be specified within this function. - \snippet containerextension/multipagewidgetplugin.h 1 - - Remember to use the Q_PLUGIN_METADATA() macro to export the - MultiPageWidgetPlugin class for use with Qt's plugin handling - classes: This macro ensures that \QD can access and construct the - custom widget. Without this macro, there is no way for \QD to use - the widget. - \section1 MultiPageWidgetExtensionFactory Class Definition The \c MultiPageWidgetExtensionFactory class inherits QExtensionFactory |