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
doc_src_designer-manual.cpp
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
3
4//! [1]
5#include <QtUiTools>
6//! [1]
7
8
9//! [2]
10void on_<object name>_<signal name>(<signal parameters>);
11//! [2]
12
13
14//! [7]
15class MyExtension: public QObject,
16 public QdesignerContainerExtension
17{
18 Q_OBJECT
19 Q_INTERFACE(QDesignerContainerExtension)
20
21 ...
22}
23//! [7]
24
25
26//! [8]
27QObject *ANewExtensionFactory::createExtension(QObject *object,
28 const QString &iid, QObject *parent) const
29{
30 if (iid != Q_TYPEID(QDesignerContainerExtension))
31 return 0;
32
33 if (MyCustomWidget *widget = qobject_cast<MyCustomWidget*>
34 (object))
35 return new MyContainerExtension(widget, parent);
36
37 return 0;
38}
39//! [8]
40
41
42//! [9]
43QObject *AGeneralExtensionFactory::createExtension(QObject *object,
44 const QString &iid, QObject *parent) const
45{
46 MyCustomWidget *widget = qobject_cast<MyCustomWidget*>(object);
47
48 if (widget && (iid == Q_TYPEID(QDesignerTaskMenuExtension))) {
49 return new MyTaskMenuExtension(widget, parent);
50
51 } else if (widget && (iid == Q_TYPEID(QDesignerContainerExtension))) {
52 return new MyContainerExtension(widget, parent);
53
54 } else {
55 return 0;
56 }
57}
58//! [9]
59
60
61//! [10]
62void MyPlugin::initialize(QDesignerFormEditorInterface *formEditor)
63{
64 if (initialized)
65 return;
66
67 QExtensionManager *manager = formEditor->extensionManager();
68 Q_ASSERT(manager != 0);
69
70 manager->registerExtensions(new MyExtensionFactory(manager),
71 Q_TYPEID(QDesignerTaskMenuExtension));
72
73 initialized = true;
74}
75//! [10]