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
qdesigneraxwidget.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3// Qt-Security score:significant reason:default
4
5#ifndef QACTIVEXPLUGINOBJECT_H
6#define QACTIVEXPLUGINOBJECT_H
7
8#include <QtCore/qpointer.h>
9#include <QtCore/qmap.h>
10#include <QtWidgets/qwidget.h>
11#include <QtGui/qpixmap.h>
12
14
15class QAxWidget;
16
17/* QDesignerAxWidget aggregates QAxWidget to keep it out of the event loop while applying
18 * properties directly.
19 * Thus, it is possible to set property values in designer that are out of range
20 * for the control, which might cause it to throw exceptions.
21 *
22 * QDesignerAxWidget is the base class following the internal naming
23 * conventions that makes the control property visible to the introspection interface.
24 *
25 * The trick to aggregate a QAxWidget is to overwrite the metaObject() function
26 * generated by moc to return the QMetaObject of QAxWidget. This is what QDesignerAxPluginWidget does. */
27
29{
30 Q_OBJECT
31 Q_PROPERTY(QString control READ control WRITE setControl RESET resetControl DESIGNABLE true)
33
34protected:
36
37public:
38 virtual ~QDesignerAxWidget();
39
40 bool loadControl(const QString &clsid);
41
42 void resetControl();
43 void setControl(const QString &clsid);
44 QString control() const;
45
46 QSize sizeHint() const override;
47 QSize minimumSizeHint() const override;
48
49 bool loaded() { return (m_axobject != 0); }
50
51 static QPixmap widgetIcon();
52
53 enum { DrawIndicator = 0x1, DrawFrame = 0x2, DrawControl = 0x4 };
54
55 unsigned drawFlags() const { return m_drawFlags; }
56 void setDrawFlags(unsigned f) { m_drawFlags = f; }
57
58protected:
59 void paintEvent(QPaintEvent *event) override;
60 QAxWidget *axobject() const { return m_axobject; }
61
62private:
63 const QSize m_defaultSize { 80, 70 };
64 unsigned m_drawFlags = DrawIndicator | DrawFrame | DrawControl;
65 QAxWidget *m_axobject = nullptr;
66 QPixmap m_axImage;
67};
68
70{
71 // No Q_OBJECT here! - meta functionality is overridden
72public:
73 explicit QDesignerAxPluginWidget(QWidget *parent);
75
76 const QMetaObject *metaObject() const override;
77 int qt_metacall(QMetaObject::Call, int, void **) override;
78
79private:
80 QMap<int, bool> m_propValues;
81};
82
83template <> inline QDesignerAxWidget *qobject_cast<QDesignerAxWidget*>(QObject *o)
84{
85 if (!o)
86 return 0;
87
88 // Unloaded state
89 if (strcmp(o->metaObject()->className(), "QDesignerAxWidget") == 0)
90 return static_cast<QDesignerAxPluginWidget*>(o);
91
92 // Loaded state with fake meta object
93 if (strcmp(o->metaObject()->className(), "QAxWidget") == 0)
94 return static_cast<QDesignerAxPluginWidget*>(o);
95
96 return 0;
97}
98
99QT_END_NAMESPACE
100
101#endif // ACTIVEQT_EXTRAINFO_H
QObject * createExtension(QObject *object, const QString &iid, QObject *parent) const override
Creates an extension specified by iid for the given object.
bool loadWidgetExtraInfo(DomWidget *ui_widget) override
Loads extra information about the specified widget, and returns true if successful; otherwise returns...
bool saveWidgetExtraInfo(DomWidget *ui_widget) override
Saves the information about the specified widget, and returns true if successful; otherwise returns f...
bool saveUiExtraInfo(DomUI *ui) override
Saves the information about the user interface specified by ui, and returns true if successful; other...
QDesignerFormEditorInterface * core() const override
\omit
QWidget * widget() const override
Returns the widget described by this extension.
bool loadUiExtraInfo(DomUI *ui) override
Loads extra information about the user interface specified by ui, and returns true if successful; oth...
static const char * controlPropertyName
QDesignerAxPluginWidget(QWidget *parent)
const QMetaObject * metaObject() const override
int qt_metacall(QMetaObject::Call, int, void **) override
virtual ~QDesignerAxPluginWidget()
QAxWidget * axobject() const
void paintEvent(QPaintEvent *event) override
This event handler can be reimplemented in a subclass to receive paint events passed in event.
QString control() const
unsigned drawFlags() const
QSize minimumSizeHint() const override
bool loadControl(const QString &clsid)
QSize sizeHint() const override
void setControl(const QString &clsid)
void setDrawFlags(unsigned f)
static QPixmap widgetIcon()
QObject * parent
Definition qobject.h:74
Combined button and popup list for selecting options.