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 QGRAPHICSPROXYWIDGET_H |
5 | #define QGRAPHICSPROXYWIDGET_H |
6 | |
7 | #include <QtWidgets/qtwidgetsglobal.h> |
8 | #include <QtWidgets/qgraphicswidget.h> |
9 | |
10 | QT_REQUIRE_CONFIG(graphicsview); |
11 | |
12 | QT_BEGIN_NAMESPACE |
13 | |
14 | class QGraphicsProxyWidgetPrivate; |
15 | |
16 | class Q_WIDGETS_EXPORT QGraphicsProxyWidget : public QGraphicsWidget |
17 | { |
18 | Q_OBJECT |
19 | public: |
20 | QGraphicsProxyWidget(QGraphicsItem *parent = nullptr, Qt::WindowFlags wFlags = Qt::WindowFlags()); |
21 | ~QGraphicsProxyWidget(); |
22 | |
23 | void setWidget(QWidget *widget); |
24 | QWidget *widget() const; |
25 | |
26 | QRectF subWidgetRect(const QWidget *widget) const; |
27 | |
28 | void setGeometry(const QRectF &rect) override; |
29 | |
30 | void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) override; |
31 | |
32 | enum { |
33 | Type = 12 |
34 | }; |
35 | int type() const override; |
36 | |
37 | QGraphicsProxyWidget *createProxyForChildWidget(QWidget *child); |
38 | |
39 | protected: |
40 | QVariant itemChange(GraphicsItemChange change, const QVariant &value) override; |
41 | |
42 | bool event(QEvent *event) override; |
43 | bool eventFilter(QObject *object, QEvent *event) override; |
44 | |
45 | void showEvent(QShowEvent *event) override; |
46 | void hideEvent(QHideEvent *event) override; |
47 | |
48 | #ifndef QT_NO_CONTEXTMENU |
49 | void contextMenuEvent(QGraphicsSceneContextMenuEvent *event) override; |
50 | #endif |
51 | |
52 | #if QT_CONFIG(draganddrop) |
53 | void dragEnterEvent(QGraphicsSceneDragDropEvent *event) override; |
54 | void dragLeaveEvent(QGraphicsSceneDragDropEvent *event) override; |
55 | void dragMoveEvent(QGraphicsSceneDragDropEvent *event) override; |
56 | void dropEvent(QGraphicsSceneDragDropEvent *event) override; |
57 | #endif |
58 | |
59 | void hoverEnterEvent(QGraphicsSceneHoverEvent *event) override; |
60 | void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) override; |
61 | void hoverMoveEvent(QGraphicsSceneHoverEvent *event) override; |
62 | void grabMouseEvent(QEvent *event) override; |
63 | void ungrabMouseEvent(QEvent *event) override; |
64 | |
65 | void mouseMoveEvent(QGraphicsSceneMouseEvent *event) override; |
66 | void mousePressEvent(QGraphicsSceneMouseEvent *event) override; |
67 | void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) override; |
68 | void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) override; |
69 | #if QT_CONFIG(wheelevent) |
70 | void wheelEvent(QGraphicsSceneWheelEvent *event) override; |
71 | #endif |
72 | |
73 | void keyPressEvent(QKeyEvent *event) override; |
74 | void keyReleaseEvent(QKeyEvent *event) override; |
75 | |
76 | void focusInEvent(QFocusEvent *event) override; |
77 | void focusOutEvent(QFocusEvent *event) override; |
78 | bool focusNextPrevChild(bool next) override; |
79 | |
80 | QVariant inputMethodQuery(Qt::InputMethodQuery query) const override; |
81 | void inputMethodEvent(QInputMethodEvent *event) override; |
82 | |
83 | QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const override; |
84 | void resizeEvent(QGraphicsSceneResizeEvent *event) override; |
85 | |
86 | protected Q_SLOTS: |
87 | QGraphicsProxyWidget *newProxyWidget(const QWidget *); |
88 | |
89 | private: |
90 | Q_DISABLE_COPY(QGraphicsProxyWidget) |
91 | Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QGraphicsProxyWidget) |
92 | Q_PRIVATE_SLOT(d_func(), void _q_removeWidgetSlot()) |
93 | |
94 | friend class QWidget; |
95 | friend class QWidgetPrivate; |
96 | friend class QGraphicsItem; |
97 | }; |
98 | |
99 | QT_END_NAMESPACE |
100 | |
101 | #endif |
102 |