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
qdockwidget.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// Qt-Security score:significant reason:default
4
5#ifndef QDYNAMICDOCKWIDGET_H
6#define QDYNAMICDOCKWIDGET_H
7
8#include <QtWidgets/qtwidgetsglobal.h>
9#include <QtWidgets/qwidget.h>
10
12
13QT_BEGIN_NAMESPACE
14
15class QDockAreaLayout;
16class QDockWidgetPrivate;
17class QMainWindow;
18class QStyleOptionDockWidget;
19
20class Q_WIDGETS_EXPORT QDockWidget : public QWidget
21{
22 Q_OBJECT
23
24 Q_PROPERTY(bool floating READ isFloating WRITE setFloating NOTIFY topLevelChanged)
25 Q_PROPERTY(DockWidgetFeatures features READ features WRITE setFeatures NOTIFY featuresChanged)
26 Q_PROPERTY(Qt::DockWidgetAreas allowedAreas READ allowedAreas
27 WRITE setAllowedAreas NOTIFY allowedAreasChanged)
28 Q_PROPERTY(QString windowTitle READ windowTitle WRITE setWindowTitle DESIGNABLE true)
29 Q_PROPERTY(Qt::DockWidgetArea dockLocation READ dockLocation WRITE setDockLocation
30 NOTIFY dockLocationChanged)
31
32public:
33 explicit QDockWidget(const QString &title, QWidget *parent = nullptr,
34 Qt::WindowFlags flags = Qt::WindowFlags());
35 explicit QDockWidget(QWidget *parent = nullptr, Qt::WindowFlags flags = Qt::WindowFlags());
36 ~QDockWidget();
37
38 QWidget *widget() const;
39 void setWidget(QWidget *widget);
40
41 enum DockWidgetFeature {
42 DockWidgetClosable = 0x01,
43 DockWidgetMovable = 0x02,
44 DockWidgetFloatable = 0x04,
45 DockWidgetVerticalTitleBar = 0x08,
46
47 DockWidgetFeatureMask = 0x0f,
48 NoDockWidgetFeatures = 0x00,
49
50 Reserved = 0xff
51 };
52 Q_DECLARE_FLAGS(DockWidgetFeatures, DockWidgetFeature)
53 Q_FLAG(DockWidgetFeatures)
54
55 void setFeatures(DockWidgetFeatures features);
56 DockWidgetFeatures features() const;
57
58 void setFloating(bool floating);
59 inline bool isFloating() const { return isWindow(); }
60
61 void setAllowedAreas(Qt::DockWidgetAreas areas);
62 Qt::DockWidgetAreas allowedAreas() const;
63
64 void setTitleBarWidget(QWidget *widget);
65 QWidget *titleBarWidget() const;
66
67 void setDockLocation(Qt::DockWidgetArea area);
68 Qt::DockWidgetArea dockLocation() const;
69
70 inline bool isAreaAllowed(Qt::DockWidgetArea area) const
71 { return (allowedAreas() & area) == area; }
72
73#ifndef QT_NO_DEBUG_STREAM
74 friend Q_WIDGETS_EXPORT QDebug operator<<(QDebug dbg, const QDockWidget *dockWidget);
75#endif
76
77#ifndef QT_NO_ACTION
78 QAction *toggleViewAction() const;
79#endif
80
81Q_SIGNALS:
82 void featuresChanged(QDockWidget::DockWidgetFeatures features);
83 void topLevelChanged(bool topLevel);
84 void allowedAreasChanged(Qt::DockWidgetAreas allowedAreas);
85 void visibilityChanged(bool visible); // ### Qt7: Deprecate this. Better listen to hide/show events
86 void dockLocationChanged(Qt::DockWidgetArea area);
87
88protected:
89 void changeEvent(QEvent *event) override;
90 void closeEvent(QCloseEvent *event) override;
91 void paintEvent(QPaintEvent *event) override;
92 bool event(QEvent *event) override;
93 virtual void initStyleOption(QStyleOptionDockWidget *option) const;
94
95private:
96 Q_DECLARE_PRIVATE(QDockWidget)
97 Q_DISABLE_COPY(QDockWidget)
98 friend class QDockAreaLayout;
99 friend class QDockWidgetItem;
100 friend class QMainWindowLayout;
101 friend class QDockWidgetLayout;
102 friend class QDockAreaLayoutInfo;
103};
104
105Q_DECLARE_OPERATORS_FOR_FLAGS(QDockWidget::DockWidgetFeatures)
106
107QT_END_NAMESPACE
108
109#endif // QDYNAMICDOCKWIDGET_H
The QDockWidget class provides a widget that can be docked inside a QMainWindow or floated as a top-l...
Definition qdockwidget.h:21
friend class QWidget
Definition qpainter.h:431
QT_REQUIRE_CONFIG(animation)
static int grow(QLayoutStruct &ls, int delta)
static QRect dockedGeometry(QWidget *widget)
static Qt::DockWidgetArea toDockWidgetArea(QInternal::DockPosition pos)
static int realMinSize(const QDockAreaLayoutInfo &info)
static int qMax(int i1, int i2, int i3)
static int shrink(QLayoutStruct &ls, int delta)
static const int zero
static int separatorMoveHelper(QList< QLayoutStruct > &list, int index, int delta, int sep)
static QInternal::DockPosition dockPosHelper(const QRect &rect, const QPoint &_pos, Qt::Orientation o, bool nestingEnabled, QDockAreaLayoutInfo::TabMode tabMode)
static void paintSep(QPainter *p, QWidget *w, const QRect &r, Qt::Orientation o, bool mouse_over)
static int realMaxSize(const QDockAreaLayoutInfo &info)
QMainWindowLayout * qt_mainwindow_layout(const QMainWindow *window)
@ StateFlagFloating
@ StateFlagVisible
QT_REQUIRE_CONFIG(dockwidget)