1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
3
4#ifndef CUSTOMWIDGET_H
5#define CUSTOMWIDGET_H
6
7#include <QtCore/qobject.h>
8#include <QtCore/qstring.h>
9#include <QtGui/qicon.h>
10
11QT_BEGIN_NAMESPACE
12
13class QWidget;
14class QDesignerFormEditorInterface;
15
16class QDesignerCustomWidgetInterface
17{
18public:
19 virtual ~QDesignerCustomWidgetInterface() = default; // ### FIXME: weak vtable
20
21 virtual QString name() const = 0;
22 virtual QString group() const = 0;
23 virtual QString toolTip() const = 0;
24 virtual QString whatsThis() const = 0;
25 virtual QString includeFile() const = 0;
26 virtual QIcon icon() const = 0;
27
28 virtual bool isContainer() const = 0;
29
30 virtual QWidget *createWidget(QWidget *parent) = 0;
31
32 virtual bool isInitialized() const { return false; }
33 virtual void initialize(QDesignerFormEditorInterface *core) { Q_UNUSED(core); }
34
35 virtual QString domXml() const
36 {
37 return QLatin1StringView("<widget class=\"%1\" name=\"%2\"/>")
38 .arg(args: name(), args: name().toLower());
39 }
40
41 virtual QString codeTemplate() const { return QString(); }
42};
43
44#define QDesignerCustomWidgetInterface_iid "org.qt-project.QDesignerCustomWidgetInterface"
45
46Q_DECLARE_INTERFACE(QDesignerCustomWidgetInterface, QDesignerCustomWidgetInterface_iid)
47
48class QDesignerCustomWidgetCollectionInterface
49{
50public:
51 virtual ~QDesignerCustomWidgetCollectionInterface() = default; // ### FIXME: weak vtable
52
53 virtual QList<QDesignerCustomWidgetInterface*> customWidgets() const = 0;
54};
55
56#define QDesignerCustomWidgetCollectionInterface_iid "org.qt-project.Qt.QDesignerCustomWidgetCollectionInterface"
57
58Q_DECLARE_INTERFACE(QDesignerCustomWidgetCollectionInterface, QDesignerCustomWidgetCollectionInterface_iid)
59
60QT_END_NAMESPACE
61
62#endif // CUSTOMWIDGET_H
63

source code of qttools/src/uiplugin/customwidget.h