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
4#ifndef QACTIVEXPLUGINOBJECT_H
5#define QACTIVEXPLUGINOBJECT_H
6
7#include <QtCore/qpointer.h>
8#include <QtCore/qmap.h>
9#include <QtWidgets/qwidget.h>
10#include <QtGui/qpixmap.h>
11
13
14class QAxWidget;
15
16/* QDesignerAxWidget aggregates QAxWidget to keep it out of the event loop while applying
17 * properties directly.
18 * Thus, it is possible to set property values in designer that are out of range
19 * for the control, which might cause it to throw exceptions.
20 *
21 * QDesignerAxWidget is the base class following the internal naming
22 * conventions that makes the control property visible to the introspection interface.
23 *
24 * The trick to aggregate a QAxWidget is to overwrite the metaObject() function
25 * generated by moc to return the QMetaObject of QAxWidget. This is what QDesignerAxPluginWidget does. */
26
28{
29 Q_OBJECT
30 Q_PROPERTY(QString control READ control WRITE setControl RESET resetControl DESIGNABLE true)
32
33protected:
35
36public:
37 virtual ~QDesignerAxWidget();
38
39 bool loadControl(const QString &clsid);
40
41 void resetControl();
42 void setControl(const QString &clsid);
43 QString control() const;
44
45 QSize sizeHint() const override;
46 QSize minimumSizeHint() const override;
47
48 bool loaded() { return (m_axobject != 0); }
49
50 static QPixmap widgetIcon();
51
52 enum { DrawIndicator = 0x1, DrawFrame = 0x2, DrawControl = 0x4 };
53
54 unsigned drawFlags() const { return m_drawFlags; }
55 void setDrawFlags(unsigned f) { m_drawFlags = f; }
56
57protected:
58 void paintEvent(QPaintEvent *event) override;
59 QAxWidget *axobject() const { return m_axobject; }
60
61private:
62 const QSize m_defaultSize { 80, 70 };
63 unsigned m_drawFlags = DrawIndicator | DrawFrame | DrawControl;
64 QAxWidget *m_axobject = nullptr;
65 QPixmap m_axImage;
66};
67
69{
70 // No Q_OBJECT here! - meta functionality is overridden
71public:
72 explicit QDesignerAxPluginWidget(QWidget *parent);
74
75 const QMetaObject *metaObject() const override;
76 int qt_metacall(QMetaObject::Call, int, void **) override;
77
78private:
79 QMap<int, bool> m_propValues;
80};
81
82template <> inline QDesignerAxWidget *qobject_cast<QDesignerAxWidget*>(QObject *o)
83{
84 if (!o)
85 return 0;
86
87 // Unloaded state
88 if (strcmp(o->metaObject()->className(), "QDesignerAxWidget") == 0)
89 return static_cast<QDesignerAxPluginWidget*>(o);
90
91 // Loaded state with fake meta object
92 if (strcmp(o->metaObject()->className(), "QAxWidget") == 0)
93 return static_cast<QDesignerAxPluginWidget*>(o);
94
95 return 0;
96}
97
98QT_END_NAMESPACE
99
100#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...
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:73
Combined button and popup list for selecting options.