File indexing completed on 2025-01-18 10:09:33
0001
0002
0003
0004 #ifndef QDYNAMICDOCKWIDGET_H
0005 #define QDYNAMICDOCKWIDGET_H
0006
0007 #include <QtWidgets/qtwidgetsglobal.h>
0008 #include <QtWidgets/qwidget.h>
0009
0010 QT_REQUIRE_CONFIG(dockwidget);
0011
0012 QT_BEGIN_NAMESPACE
0013
0014 class QDockAreaLayout;
0015 class QDockWidgetPrivate;
0016 class QMainWindow;
0017 class QStyleOptionDockWidget;
0018
0019 class Q_WIDGETS_EXPORT QDockWidget : public QWidget
0020 {
0021 Q_OBJECT
0022
0023 Q_PROPERTY(bool floating READ isFloating WRITE setFloating)
0024 Q_PROPERTY(DockWidgetFeatures features READ features WRITE setFeatures NOTIFY featuresChanged)
0025 Q_PROPERTY(Qt::DockWidgetAreas allowedAreas READ allowedAreas
0026 WRITE setAllowedAreas NOTIFY allowedAreasChanged)
0027 Q_PROPERTY(QString windowTitle READ windowTitle WRITE setWindowTitle DESIGNABLE true)
0028
0029 public:
0030 explicit QDockWidget(const QString &title, QWidget *parent = nullptr,
0031 Qt::WindowFlags flags = Qt::WindowFlags());
0032 explicit QDockWidget(QWidget *parent = nullptr, Qt::WindowFlags flags = Qt::WindowFlags());
0033 ~QDockWidget();
0034
0035 QWidget *widget() const;
0036 void setWidget(QWidget *widget);
0037
0038 enum DockWidgetFeature {
0039 DockWidgetClosable = 0x01,
0040 DockWidgetMovable = 0x02,
0041 DockWidgetFloatable = 0x04,
0042 DockWidgetVerticalTitleBar = 0x08,
0043
0044 DockWidgetFeatureMask = 0x0f,
0045 NoDockWidgetFeatures = 0x00,
0046
0047 Reserved = 0xff
0048 };
0049 Q_DECLARE_FLAGS(DockWidgetFeatures, DockWidgetFeature)
0050 Q_FLAG(DockWidgetFeatures)
0051
0052 void setFeatures(DockWidgetFeatures features);
0053 DockWidgetFeatures features() const;
0054
0055 void setFloating(bool floating);
0056 inline bool isFloating() const { return isWindow(); }
0057
0058 void setAllowedAreas(Qt::DockWidgetAreas areas);
0059 Qt::DockWidgetAreas allowedAreas() const;
0060
0061 void setTitleBarWidget(QWidget *widget);
0062 QWidget *titleBarWidget() const;
0063
0064 inline bool isAreaAllowed(Qt::DockWidgetArea area) const
0065 { return (allowedAreas() & area) == area; }
0066
0067 #ifndef QT_NO_DEBUG_STREAM
0068 friend Q_WIDGETS_EXPORT QDebug operator<<(QDebug dbg, const QDockWidget *dockWidget);
0069 #endif
0070
0071 #ifndef QT_NO_ACTION
0072 QAction *toggleViewAction() const;
0073 #endif
0074
0075 Q_SIGNALS:
0076 void featuresChanged(QDockWidget::DockWidgetFeatures features);
0077 void topLevelChanged(bool topLevel);
0078 void allowedAreasChanged(Qt::DockWidgetAreas allowedAreas);
0079 void visibilityChanged(bool visible);
0080 void dockLocationChanged(Qt::DockWidgetArea area);
0081
0082 protected:
0083 void changeEvent(QEvent *event) override;
0084 void closeEvent(QCloseEvent *event) override;
0085 void paintEvent(QPaintEvent *event) override;
0086 bool event(QEvent *event) override;
0087 virtual void initStyleOption(QStyleOptionDockWidget *option) const;
0088
0089 private:
0090 Q_DECLARE_PRIVATE(QDockWidget)
0091 Q_DISABLE_COPY(QDockWidget)
0092 friend class QDockAreaLayout;
0093 friend class QDockWidgetItem;
0094 friend class QMainWindowLayout;
0095 friend class QDockWidgetLayout;
0096 friend class QDockAreaLayoutInfo;
0097 };
0098
0099 Q_DECLARE_OPERATORS_FOR_FLAGS(QDockWidget::DockWidgetFeatures)
0100
0101 QT_END_NAMESPACE
0102
0103 #endif