summaryrefslogtreecommitdiffstats
path: root/examples/designer/doc/src/taskmenuextension.qdoc
diff options
context:
space:
mode:
Diffstat (limited to 'examples/designer/doc/src/taskmenuextension.qdoc')
-rw-r--r--examples/designer/doc/src/taskmenuextension.qdoc120
1 files changed, 52 insertions, 68 deletions
diff --git a/examples/designer/doc/src/taskmenuextension.qdoc b/examples/designer/doc/src/taskmenuextension.qdoc
index 6b5df136a..6a9521a7c 100644
--- a/examples/designer/doc/src/taskmenuextension.qdoc
+++ b/examples/designer/doc/src/taskmenuextension.qdoc
@@ -1,44 +1,22 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the documentation of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:FDL$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU Free Documentation License Usage
-** Alternatively, this file may be used under the terms of the GNU Free
-** Documentation License version 1.3 as published by the Free Software
-** Foundation and appearing in the file included in the packaging of
-** this file. Please review the following information to ensure
-** the GNU Free Documentation License version 1.3 requirements
-** will be met: https://www.gnu.org/licenses/fdl-1.3.html.
-** $QT_END_LICENSE$
-**
-****************************************************************************/
+// Copyright (C) 2016 The Qt Company Ltd.
+// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
/*!
\example taskmenuextension
+ \examplecategory {Desktop}
+ \meta tags {widgets,designer}
\ingroup examples-designer
- \title Task Menu Extension Example
+ \title Task Menu Extension
\brief Creating a custom widget plugin for \QD and providing custom task
menu entries that are associated with the plugin.
The Task Menu Extension example shows how to create a custom
- widget plugin for \l {Qt Designer Manual}{\QD}, and how to to use
+ widget plugin for \l {Qt Widgets Designer Manual}{\QD}, and how to use
the QDesignerTaskMenuExtension class to provide custom task menu
entries associated with the plugin.
- \image taskmenuextension-example-faded.png
+ \image taskmenuextension-example.webp
To provide a custom widget that can be used with \QD, we need to
supply a self-contained implementation. In this example we use a
@@ -57,18 +35,18 @@
in \QD.
\li QDesignerMemberSheetExtension provides an extension that allows
you to manipulate a widget's member functions which is displayed
- when configuring connections using Qt Designer's mode for editing
+ when configuring connections using \QD's mode for editing
signals and slots.
\li QDesignerPropertySheetExtension provides an extension that
allows you to manipulate a widget's properties which is displayed
- in Qt Designer's property editor.
+ in \QD's property editor.
\li QDesignerTaskMenuExtension provides an extension that allows
you to add custom menu entries to \QD's task menu.
\endlist
You can use all the extensions following the same pattern as in
this example, only replacing the respective extension base
- class. For more information, see the \l{Qt Designer C++ Classes}.
+ class. For more information, see the \l{Qt Widgets Designer C++ Classes}.
The Task Menu Extension example consists of five classes:
@@ -95,30 +73,21 @@
TicTacToeDialog class before we take a quick look at the \c
TicTacToe widget's class definition.
- \section1 The Project File: taskmenuextension.pro
+ \section1 Project files
- The project file must contain some additional information to
- ensure that the plugin will work as expected:
+ \section2 CMake
- \snippet taskmenuextension/taskmenuextension.pro 0
- \snippet taskmenuextension/taskmenuextension.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 \c CONFIG variable is set to \c plugin, which ensures that \c qmake
- considers the custom widget a plugin library.
+ The project files need to state that a plugin linking
+ to the \QD libraries is to be built:
- 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 taskmenuextension/CMakeLists.txt 0
+ \codeline
+ \snippet taskmenuextension/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 taskmenuextension/taskmenuextension.pro 2
+ \snippet taskmenuextension/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
@@ -130,21 +99,33 @@
target path for the project and adding it to the list of items to
install:
- \snippet doc/snippets/doc_src_examples_taskmenuextension.pro 0
+ \snippet taskmenuextension/CMakeLists.txt 3
+ \snippet taskmenuextension/CMakeLists.txt 4
- The task menu extension is created as a library, and will be
+ The task menu 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
- For more information about plugins, see the \l {How to Create Qt
- Plugins} documentation.
+ The following example shows how to link a plugin to the \QD libraries:
+
+ \snippet taskmenuextension/taskmenuextension.pro 0
+ \codeline
+ \snippet taskmenuextension/taskmenuextension.pro 1
+
+ The following example shows how to add the header and source files of the
+ widget:
+
+ \snippet taskmenuextension/taskmenuextension.pro 2
+
+ The following example shows how to install a plugin to the \QD's plugin path:
+
+ \snippet taskmenuextension/taskmenuextension.pro 3
\section1 TicTacToePlugin Class Definition
@@ -153,7 +134,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 taskmenuextension/tictactoeplugin.h 0
@@ -189,7 +173,7 @@
The \c initialize() function takes a QDesignerFormEditorInterface
object as argument. The QDesignerFormEditorInterface class
- provides access to Qt Designer's components.
+ provides access to \QD's components.
In \QD you can create two kinds of plugins: custom widget plugins
and tool plugins. QDesignerFormEditorInterface provides access to
@@ -241,7 +225,7 @@
We omit to reimplement the
QDesignerCustomWidgetInterface::domXml() function (which include
default settings for the widget in the standard XML format used by
- Qt Designer), since no default values are necessary.
+ \QD), since no default values are necessary.
\snippet taskmenuextension/tictactoeplugin.h 1
@@ -292,7 +276,7 @@
\section1 TicTacToeTaskMenu Class Definition
- \image taskmenuextension-menu.png
+ \image taskmenuextension-menu.webp
The \c TicTacToeTaskMenu class inherits QDesignerTaskMenuExtension
which allows you to add custom entries (in the form of QActions)
@@ -341,7 +325,7 @@
\section1 TicTacToeDialog Class Definition
- \image taskmenuextension-dialog.png
+ \image taskmenuextension-dialog.webp
The \c TicTacToeDialog class inherits QDialog. The dialog lets the
user modify the state of the currently selected Tic-Tac-Toe
@@ -390,8 +374,8 @@
QDesignerFormWindowInterface provides you with information about
the associated form window as well as allowing you to alter its
properties. The interface is not intended to be instantiated
- directly, but to provide access to Qt Designer's current form
- windows controlled by Qt Designer's form window manager.
+ directly, but to provide access to \QD's current form
+ windows controlled by \QD's form window manager.
If you are looking for the form window containing a specific
widget, you can use the static