Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
designer-custom-widgets.qdoc
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
3
4/*!
5 \page qtdesigner-components.html
6 \title Creating and Using Components for Qt Widgets Designer
7 \brief How to create and use custom widget plugins.
8 \ingroup best-practices
9
10 \section1 Creating Custom Widget Plugins
11
12 When implementing a custom widget plugin for \QD, you must
13 subclass QDesignerCustomWidgetInterface to expose your custom
14 widget to \QD. A single custom widget plugin is built as a
15 separate library. If you want to include several custom widget
16 plugins in the same library, you must in addition subclass
17 QDesignerCustomWidgetCollectionInterface.
18
19 To provide your custom widget plugin with the expected behavior
20 and functionality within \QD's workspace you can subclass the
21 associated extension classes:
22
23 The QDesignerContainerExtension class allows you to add pages to a
24 custom multi-page container. The QDesignerTaskMenuExtension class
25 allows you to add custom menu entries to \QD's task menu. The
26 QDesignerMemberSheetExtension class allows you to manipulate a
27 widget's member functions which is displayed when configuring
28 connections using \QD's mode for editing signals and slots. And
29 finally, the QDesignerPropertySheetExtension class allows you to
30 manipulate a widget's properties which is displayed in \QD's
31 property editor.
32
33 \image qtdesignerextensions.png
34
35 In \QD the extensions are not created until they are required. For
36 that reason, when implementing extensions, you must also subclass
37 QExtensionFactory, i.e create a class that is able to make
38 instances of your extensions. In addition, you must make \QD's
39 extension manager register your factory; the extension manager
40 controls the construction of extensions as they are required, and
41 you can access it through QDesignerFormEditorInterface and
42 QExtensionManager.
43
44 For a complete example creating a custom widget plugin with an
45 extension, see the \l {taskmenuextension}{Task Menu
46 Extension} or \l {containerextension}{Container
47 Extension} examples.
48
49 \section1 Retrieving Access to \QD Components
50
51 The purpose of the classes mentioned in this section is to provide
52 access to \QD's components, managers and workspace, and they are
53 not intended to be instantiated directly.
54
55 \QD is composed by several components. It has an action editor, a
56 property editor, widget box and object inspector which you can
57 view in its workspace.
58
59 \image qtdesignerscreenshot.png
60
61 \QD also has an object that works behind the scene; it contains
62 the logic that integrates all of \QD's components into a coherent
63 application. You can access this object, using the
64 QDesignerFormEditorInterface, to retrieve interfaces to \QD's
65 components:
66
67 \list
68 \li QDesignerActionEditorInterface
69 \li QDesignerObjectInspectorInterface
70 \li QDesignerPropertyEditorInterface
71 \li QDesignerWidgetBoxInterface
72 \endlist
73
74 In addition, you can use QDesignerFormEditorInterface to retrieve
75 interfaces to \QD's extension manager (QExtensionManager) and form
76 window manager (QDesignerFormWindowManagerInterface). The
77 extension manager controls the construction of extensions as they
78 are required, while the form window manager controls the form
79 windows appearing in \QD's workspace.
80
81 Once you have an interface to \QD's form window manager
82 (QDesignerFormWindowManagerInterface), you also have access to all
83 the form windows currently appearing in \QD's workspace: The
84 QDesignerFormWindowInterface class allows you to query and
85 manipulate the form windows, and it provides an interface to the
86 form windows' cursors. QDesignerFormWindowCursorInterface is a
87 convenience class allowing you to query and modify a given form
88 window's widget selection, and in addition modify the properties
89 of all the form's widgets.
90
91 \section1 Creating User Interfaces at Run-Time
92
93 The \c QtDesigner module contains the QFormBuilder class that
94 provides a mechanism for dynamically creating user interfaces at
95 run-time, based on UI files created with \QD. This class is
96 typically used by custom components and applications that embed
97 \QD. Standalone applications that need to dynamically generate
98 user interfaces at run-time use the QUiLoader class, found in
99 the QtUiTools module.
100
101 For a complete example using QUiLoader, see
102 the \l {calculatorbuilder}{Calculator Builder example}.
103
104 \sa {Qt Widgets Designer Manual}, {Qt UI Tools}
105*/