Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-14 09:20:49

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