Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qdockwidget_p.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
4#ifndef QDYNAMICDOCKWIDGET_P_H
5#define QDYNAMICDOCKWIDGET_P_H
6
7//
8// W A R N I N G
9// -------------
10//
11// This file is not part of the Qt API. It exists purely as an
12// implementation detail. This header file may change from version to
13// version without notice, or even be removed.
14//
15// We mean it.
16//
17
18#include <QtWidgets/private/qtwidgetsglobal_p.h>
19#include "QtWidgets/qstyleoption.h"
20#include "private/qwidget_p.h"
21#include "QtWidgets/qboxlayout.h"
22#include "QtWidgets/qdockwidget.h"
23
24#if QT_CONFIG(tabwidget)
25# include "QtWidgets/qtabwidget.h"
26#endif
27
29
31
32class QGridLayout;
35class QSpacerItem;
36class QDockWidgetItem;
37
39{
40 Q_DECLARE_PUBLIC(QDockWidget)
41
42 struct DragState {
43 QPoint pressPos;
44 QPoint globalPressPos;
45 QPoint widgetInitialPos;
46 bool dragging;
47 QLayoutItem *widgetItem;
48 bool ownWidgetItem;
49 bool nca;
50 bool ctrlDrag;
51 };
52
53public:
54 enum class DragScope {
55 Group,
56 Widget
57 };
58
59 enum class EndDragMode {
61 Abort
62 };
63
64 void init();
65 void toggleView(bool);
66 void toggleTopLevel();
67
68 void updateButtons();
70
71#if QT_CONFIG(tabwidget)
73#endif
74
75 DragState *state = nullptr;
76
77 QDockWidget::DockWidgetFeatures features = QDockWidget::DockWidgetClosable
79 Qt::DockWidgetAreas allowedAreas = Qt::AllDockWidgetAreas;
80
82
83#ifndef QT_NO_ACTION
85#endif
86
87// QMainWindow *findMainWindow(QWidget *widget) const;
91
96 void setWindowState(bool floating, bool unplug = false, const QRect &rect = QRect());
98 void initDrag(const QPoint &pos, bool nca);
99 void startDrag(DragScope scope);
103
104 void unplug(const QRect &rect);
105 void plug(const QRect &rect);
106 void setResizerActive(bool active);
107
108 bool isAnimating() const;
109 bool isTabbed() const;
110
111private:
112 QWidgetResizeHandler *resizer = nullptr;
113};
114
115class Q_WIDGETS_EXPORT QDockWidgetLayout : public QLayout
116{
118public:
119 QDockWidgetLayout(QWidget *parent = nullptr);
121 void addItem(QLayoutItem *item) override;
122 QLayoutItem *itemAt(int index) const override;
123 QLayoutItem *takeAt(int index) override;
124 int count() const override;
125
126 QSize maximumSize() const override;
127 QSize minimumSize() const override;
128 QSize sizeHint() const override;
129
130 QSize sizeFromContent(const QSize &content, bool floating) const;
131
132 void setGeometry(const QRect &r) override;
133
134 enum Role { Content, CloseButton, FloatButton, TitleBar, RoleCount };
135 QWidget *widgetForRole(Role r) const;
136 void setWidgetForRole(Role r, QWidget *w);
137 QLayoutItem *itemForRole(Role r) const;
138
139 QRect titleArea() const { return _titleArea; }
140
141 int minimumTitleWidth() const;
142 int titleHeight() const;
144 static bool wmSupportsNativeWindowDeco();
145 bool nativeWindowDeco() const;
146 bool nativeWindowDeco(bool floating) const;
147
148 void setVerticalTitleBar(bool b);
149
151
152private:
153 QList<QLayoutItem *> item_list;
154 QRect _titleArea;
155};
156
157/* The size hints of a QDockWidget will depend on whether it is docked or not.
158 This layout item always returns the size hints as if the dock widget was docked. */
159
161{
162public:
164 QSize minimumSize() const override;
165 QSize maximumSize() const override;
166 QSize sizeHint() const override;
167
168private:
169 inline QLayoutItem *dockWidgetChildItem() const;
170 inline QDockWidgetLayout *dockWidgetLayout() const;
171};
172
173inline QLayoutItem *QDockWidgetItem::dockWidgetChildItem() const
174{
175 if (QDockWidgetLayout *layout = dockWidgetLayout())
176 return layout->itemForRole(QDockWidgetLayout::Content);
177 return nullptr;
178}
179
180inline QDockWidgetLayout *QDockWidgetItem::dockWidgetLayout() const
181{
182 QWidget *w = widget();
183 if (w != nullptr)
184 return qobject_cast<QDockWidgetLayout*>(w->layout());
185 return nullptr;
186}
187
189
190#endif // QDYNAMICDOCKWIDGET_P_H
The QAction class provides an abstraction for user commands that can be added to different user inter...
Definition qaction.h:30
QDockWidgetItem(QDockWidget *dockWidget)
QSize minimumSize() const override
Implemented in subclasses to return the minimum size of this item.
QSize maximumSize() const override
Implemented in subclasses to return the maximum size of this item.
QSize sizeHint() const override
Implemented in subclasses to return the preferred size of this item.
QRect titleArea() const
static Qt::DockWidgetArea toDockWidgetArea(QInternal::DockPosition pos)
void plug(const QRect &rect)
bool isAnimating() const
void setResizerActive(bool active)
QAction * toggleViewAction
void setWindowState(bool floating, bool unplug=false, const QRect &rect=QRect())
void startDrag(DragScope scope)
void moveEvent(QMoveEvent *event)
void initDrag(const QPoint &pos, bool nca)
void endDrag(EndDragMode mode)
void nonClientAreaMouseEvent(QMouseEvent *event)
bool mouseDoubleClickEvent(QMouseEvent *event)
bool mousePressEvent(QMouseEvent *event)
void recalculatePressPos(QResizeEvent *event)
Qt::DockWidgetAreas allowedAreas
bool mouseReleaseEvent(QMouseEvent *event)
bool mouseMoveEvent(QMouseEvent *event)
void unplug(const QRect &rect)
QDockWidget::DockWidgetFeatures features
bool isTabbed() const
The QDockWidget class provides a widget that can be docked inside a QMainWindow or floated as a top-l...
Definition qdockwidget.h:20
@ DockWidgetFloatable
Definition qdockwidget.h:41
\reentrant
Definition qfont.h:22
The QGridLayout class lays out widgets in a grid.
Definition qgridlayout.h:21
The QLayoutItem class provides an abstract item that a QLayout manipulates.
Definition qlayoutitem.h:25
virtual QLayout * layout()
If this item is a QLayout, it is returned as a QLayout; otherwise \nullptr is returned.
The QLayout class is the base class of geometry managers.
Definition qlayout.h:26
\inmodule QtGui
Definition qevent.h:196
The QMoveEvent class contains event parameters for move events.
Definition qevent.h:502
\inmodule QtCore\reentrant
Definition qpoint.h:25
\inmodule QtCore\reentrant
Definition qrect.h:30
The QResizeEvent class contains event parameters for resize events.
Definition qevent.h:548
\inmodule QtCore
Definition qsize.h:25
The QSpacerItem class provides blank space in a layout.
Definition qlayoutitem.h:57
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
TabPosition
This enum type defines where QTabWidget draws the tab row:
Definition qtabwidget.h:74
The QWidgetItem class is a layout item that represents a widget.
Definition qlayoutitem.h:86
QWidget * widget() const override
Returns the widget managed by this item.
The QWidget class is the base class of all user interface objects.
Definition qwidget.h:99
rect
[4]
Combined button and popup list for selecting options.
DockWidgetArea
@ AllDockWidgetAreas
GLboolean GLboolean GLboolean b
GLenum mode
GLfloat GLfloat GLfloat w
[0]
GLuint index
[2]
GLboolean r
[2]
GLenum GLenum GLsizei count
struct _cl_event * event
#define QT_REQUIRE_CONFIG(feature)
#define Q_OBJECT
scene addItem(form)
QGraphicsItem * item
QDockWidget * dockWidget
[0]