qgraphicsproxywidget.h 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. /****************************************************************************
  2. **
  3. ** Copyright (C) 2016 The Qt Company Ltd.
  4. ** Contact: https://www.qt.io/licensing/
  5. **
  6. ** This file is part of the QtWidgets module of the Qt Toolkit.
  7. **
  8. ** $QT_BEGIN_LICENSE:LGPL$
  9. ** Commercial License Usage
  10. ** Licensees holding valid commercial Qt licenses may use this file in
  11. ** accordance with the commercial license agreement provided with the
  12. ** Software or, alternatively, in accordance with the terms contained in
  13. ** a written agreement between you and The Qt Company. For licensing terms
  14. ** and conditions see https://www.qt.io/terms-conditions. For further
  15. ** information use the contact form at https://www.qt.io/contact-us.
  16. **
  17. ** GNU Lesser General Public License Usage
  18. ** Alternatively, this file may be used under the terms of the GNU Lesser
  19. ** General Public License version 3 as published by the Free Software
  20. ** Foundation and appearing in the file LICENSE.LGPL3 included in the
  21. ** packaging of this file. Please review the following information to
  22. ** ensure the GNU Lesser General Public License version 3 requirements
  23. ** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
  24. **
  25. ** GNU General Public License Usage
  26. ** Alternatively, this file may be used under the terms of the GNU
  27. ** General Public License version 2.0 or (at your option) the GNU General
  28. ** Public license version 3 or any later version approved by the KDE Free
  29. ** Qt Foundation. The licenses are as published by the Free Software
  30. ** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
  31. ** included in the packaging of this file. Please review the following
  32. ** information to ensure the GNU General Public License requirements will
  33. ** be met: https://www.gnu.org/licenses/gpl-2.0.html and
  34. ** https://www.gnu.org/licenses/gpl-3.0.html.
  35. **
  36. ** $QT_END_LICENSE$
  37. **
  38. ****************************************************************************/
  39. #ifndef QGRAPHICSPROXYWIDGET_H
  40. #define QGRAPHICSPROXYWIDGET_H
  41. #include <QtWidgets/qgraphicswidget.h>
  42. QT_BEGIN_NAMESPACE
  43. #if !defined(QT_NO_GRAPHICSVIEW)
  44. class QGraphicsProxyWidgetPrivate;
  45. class Q_WIDGETS_EXPORT QGraphicsProxyWidget : public QGraphicsWidget
  46. {
  47. Q_OBJECT
  48. public:
  49. QGraphicsProxyWidget(QGraphicsItem *parent = Q_NULLPTR, Qt::WindowFlags wFlags = Qt::WindowFlags());
  50. ~QGraphicsProxyWidget();
  51. void setWidget(QWidget *widget);
  52. QWidget *widget() const;
  53. QRectF subWidgetRect(const QWidget *widget) const;
  54. void setGeometry(const QRectF &rect) Q_DECL_OVERRIDE;
  55. void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) Q_DECL_OVERRIDE;
  56. enum {
  57. Type = 12
  58. };
  59. int type() const Q_DECL_OVERRIDE;
  60. QGraphicsProxyWidget *createProxyForChildWidget(QWidget *child);
  61. protected:
  62. QVariant itemChange(GraphicsItemChange change, const QVariant &value) Q_DECL_OVERRIDE;
  63. bool event(QEvent *event) Q_DECL_OVERRIDE;
  64. bool eventFilter(QObject *object, QEvent *event) Q_DECL_OVERRIDE;
  65. void showEvent(QShowEvent *event) Q_DECL_OVERRIDE;
  66. void hideEvent(QHideEvent *event) Q_DECL_OVERRIDE;
  67. #ifndef QT_NO_CONTEXTMENU
  68. void contextMenuEvent(QGraphicsSceneContextMenuEvent *event) Q_DECL_OVERRIDE;
  69. #endif
  70. #ifndef QT_NO_DRAGANDDROP
  71. void dragEnterEvent(QGraphicsSceneDragDropEvent *event) Q_DECL_OVERRIDE;
  72. void dragLeaveEvent(QGraphicsSceneDragDropEvent *event) Q_DECL_OVERRIDE;
  73. void dragMoveEvent(QGraphicsSceneDragDropEvent *event) Q_DECL_OVERRIDE;
  74. void dropEvent(QGraphicsSceneDragDropEvent *event) Q_DECL_OVERRIDE;
  75. #endif
  76. void hoverEnterEvent(QGraphicsSceneHoverEvent *event) Q_DECL_OVERRIDE;
  77. void hoverLeaveEvent(QGraphicsSceneHoverEvent *event) Q_DECL_OVERRIDE;
  78. void hoverMoveEvent(QGraphicsSceneHoverEvent *event) Q_DECL_OVERRIDE;
  79. void grabMouseEvent(QEvent *event) Q_DECL_OVERRIDE;
  80. void ungrabMouseEvent(QEvent *event) Q_DECL_OVERRIDE;
  81. void mouseMoveEvent(QGraphicsSceneMouseEvent *event) Q_DECL_OVERRIDE;
  82. void mousePressEvent(QGraphicsSceneMouseEvent *event) Q_DECL_OVERRIDE;
  83. void mouseReleaseEvent(QGraphicsSceneMouseEvent *event) Q_DECL_OVERRIDE;
  84. void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) Q_DECL_OVERRIDE;
  85. #ifndef QT_NO_WHEELEVENT
  86. void wheelEvent(QGraphicsSceneWheelEvent *event) Q_DECL_OVERRIDE;
  87. #endif
  88. void keyPressEvent(QKeyEvent *event) Q_DECL_OVERRIDE;
  89. void keyReleaseEvent(QKeyEvent *event) Q_DECL_OVERRIDE;
  90. void focusInEvent(QFocusEvent *event) Q_DECL_OVERRIDE;
  91. void focusOutEvent(QFocusEvent *event) Q_DECL_OVERRIDE;
  92. bool focusNextPrevChild(bool next) Q_DECL_OVERRIDE;
  93. QVariant inputMethodQuery(Qt::InputMethodQuery query) const Q_DECL_OVERRIDE;
  94. void inputMethodEvent(QInputMethodEvent *event) Q_DECL_OVERRIDE;
  95. QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const Q_DECL_OVERRIDE;
  96. void resizeEvent(QGraphicsSceneResizeEvent *event) Q_DECL_OVERRIDE;
  97. protected Q_SLOTS:
  98. QGraphicsProxyWidget *newProxyWidget(const QWidget *);
  99. private:
  100. Q_DISABLE_COPY(QGraphicsProxyWidget)
  101. Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QGraphicsProxyWidget)
  102. Q_PRIVATE_SLOT(d_func(), void _q_removeWidgetSlot())
  103. friend class QWidget;
  104. friend class QWidgetPrivate;
  105. friend class QGraphicsItem;
  106. };
  107. #endif
  108. QT_END_NAMESPACE
  109. #endif