QtCanpool 3.3.0
载入中...
搜索中...
未找到
dockwidget.h
浏览该文件的文档.
1
5#pragma once
6
7#include "qxdock_global.h"
8#include <QFrame>
9#include <functional>
10
11class QToolBar;
12class QXmlStreamWriter;
13
15
16class DockWindow;
17class DockContainer;
18class DockPanel;
19class DockTab;
20class DockSideTab;
21class DockAutoHideContainer;
22class DockFloatingContainer;
23
24class DockWidgetPrivate;
25
30class QX_DOCK_EXPORT DockWidget : public QFrame
31{
32 Q_OBJECT
33public:
34 using Super = QFrame;
35
37 // dock widget has a close button
38 DockWidgetClosable = 0x001,
39 // dock widget is movable and can be moved to a new position in the current dock container
40 DockWidgetMovable = 0x002,
41 // dock widget can be dragged into a floating window
42 DockWidgetFloatable = 0x004,
43 // deletes the dock widget when it is closed
44 DockWidgetDeleteOnClose = 0x008,
45 // clicking the close button will not close the dock widget but emits the closeRequested() signal instead
46 CustomCloseHandling = 0x010,
47 // if this is enabled, a dock widget can get focus highlighting
48 DockWidgetFocusable = 0x020,
49 // dock widget will be closed when the dock area hosting it is closed
50 DockWidgetForceCloseWithArea = 0x040,
51 // dock widget tab will never be shown if this flag is set
52 NoTab = 0x080,
53 // deletes only the contained widget on close, keeping the dock widget intact and in place.
54 // Attempts to rebuild the contents widget on show if there is a widget factory set.
55 DeleteContentOnClose = 0x100,
56 // dock widget can be pinned and added to an auto hide dock container
57 DockWidgetPinnable = 0x200,
58
59 DefaultDockWidgetFeatures =
60 DockWidgetClosable | DockWidgetMovable | DockWidgetFloatable | DockWidgetFocusable | DockWidgetPinnable,
61 AllDockWidgetFeatures = DefaultDockWidgetFeatures | DockWidgetDeleteOnClose | CustomCloseHandling,
62 DockWidgetAlwaysCloseAndDelete = DockWidgetForceCloseWithArea | DockWidgetDeleteOnClose,
63 GloballyLockableFeatures = DockWidgetClosable | DockWidgetMovable | DockWidgetFloatable | DockWidgetPinnable,
64 NoDockWidgetFeatures = 0x000
65 };
66 Q_DECLARE_FLAGS(DockWidgetFeatures, DockWidgetFeature)
77 ActionModeShow
78 };
97
120
121 enum State {
124 StateFloating
125 };
126
129 ToolBarStyleFromDockWidget
130 };
131public:
132 explicit DockWidget(const QString &title, QWidget *parent = nullptr);
133 ~DockWidget();
134
135 void setWidget(QWidget *w, WidgetInsertMode insertMode = AutoScrollArea);
136 QWidget *widget() const;
137 QWidget *takeWidget();
138
139 DockTab *tab() const;
140
141 DockWidgetFeatures features() const;
142 void setFeatures(DockWidgetFeatures features);
143 void setFeature(DockWidgetFeature flag, bool on);
144 void notifyFeaturesChanged();
145
146 DockWindow *dockWindow() const;
147 DockContainer *dockContainer() const;
148 DockFloatingContainer *dockFloatingContainer() const;
149 DockPanel *dockPanel() const;
150
151 bool isFloating() const;
152 bool isInFloatingContainer() const;
153 bool isClosed() const;
154 bool isFullScreen() const;
155 bool isTabbed() const;
156 bool isCurrentTab() const;
157 bool isCentralWidget() const;
158
159 QAction *toggleViewAction() const;
160 void setToggleViewAction(QAction *action);
161 void setToggleViewActionMode(ToggleViewActionMode mode);
162 void setToggleViewActionChecked(bool checked);
163
164 virtual QList<QAction *> titleBarActions() const;
165 void setTitleBarActions(QList<QAction *> actions);
166
167 MinimumSizeHintMode minimumSizeHintMode() const;
168 void setMinimumSizeHintMode(MinimumSizeHintMode mode);
169 virtual QSize minimumSizeHint() const override;
170
171 QIcon icon() const;
172 void setIcon(const QIcon &icon);
173
174 QToolBar *toolBar() const;
175 void setToolBar(QToolBar *toolBar);
176
177 ToolBarStyleSource toolBarStyleSource() const;
178 void setToolBarStyleSource(ToolBarStyleSource source);
179 Qt::ToolButtonStyle toolBarStyle(State state) const;
180 void setToolBarStyle(Qt::ToolButtonStyle style, State state);
181 QSize toolBarIconSize(State state) const;
182 void setToolBarIconSize(const QSize &iconSize, State state);
183
184 DockSideTab *sideTab() const;
185 void setSideTab(DockSideTab *sideTab);
186 bool isAutoHide() const;
187 DockAutoHideContainer *autoHideContainer() const;
188 Qx::DockSideBarArea autoHideArea() const;
189
190 using FactoryFunc = std::function<QWidget *(QWidget *)>;
191 void setWidgetFactory(FactoryFunc createWidget, WidgetInsertMode insertMode = AutoScrollArea);
192
193#ifndef QT_NO_TOOLTIP
194 void setTabToolTip(const QString &text);
195#endif
196
197public Q_SLOTS:
198 void toggleView(bool open = true);
199 void deleteDockWidget();
200 void closeDockWidget();
201 void requestCloseDockWidget();
202 void setAutoHide(bool enable, Qx::DockSideBarArea area = Qx::DockSideBarNone, int tabIndex = -1);
203 void toggleAutoHide(Qx::DockSideBarArea area = Qx::DockSideBarNone);
204 void setAsCurrentTab();
205 void raise();
206 void showFullScreen();
207 void showNormal();
208 void setFloating();
209
210private Q_SLOTS:
211 void setToolBarFloatingStyle(bool floating);
212
213Q_SIGNALS:
214 void viewToggled(bool open);
216 void closed();
222 void topLevelChanged(bool topLevel);
223 void titleChanged(const QString &title);
229 void visibilityChanged(bool visible);
230 void featuresChanged(DockWidget::DockWidgetFeatures features);
231protected:
232 void setDockWindow(DockWindow *window);
233 void setDockPanel(DockPanel *panel);
234 void setClosedState(bool closed);
235 static void emitTopLevelEventForWidget(DockWidget *topLevelDockWidget, bool floating);
236 void emitTopLevelChanged(bool floating);
237 void toggleViewInternal(bool open);
238 bool closeDockWidgetInternal(bool forceClose = false);
239 void flagAsUnassigned();
240 void saveState(QXmlStreamWriter &s) const;
241protected:
242 virtual bool event(QEvent *e) override;
243private:
245 friend class DockContainer;
246 friend class DockPanel;
247 friend class DockWindow;
248 friend class DockWindowPrivate;
249 friend class DockTitleBarPrivate;
252};
253
Auto hide container for hosting an auto hide dock widget
Container that manages a number of dock panels with single dock widgets or tabyfied dock widgets in e...
This implements a floating widget that is a dock container that accepts docking of dock widgets like ...
DockPanel manages multiple instances of DockWidgets.
Definition dockpanel.h:31
A dock widget Side tab that shows a title or an icon.
Definition docksidetab.h:23
The DockWidget class provides a widget that can be docked inside a DockWindow or floated as a top-lev...
Definition dockwidget.h:31
void titleChanged(const QString &title)
std::function< QWidget *(QWidget *)> FactoryFunc
Definition dockwidget.h:190
void viewToggled(bool open)
WidgetInsertMode
Sets the widget for the dock widget to widget.
Definition dockwidget.h:115
ToggleViewActionMode
This mode configures the behavior of the toggle view action.
Definition dockwidget.h:75
MinimumSizeHintMode
The mode of the minimumSizeHint() that is returned by the DockWidget minimumSizeHint() function.
Definition dockwidget.h:91
@ MinimumSizeHintFromContentMinimumSize
Definition dockwidget.h:95
@ MinimumSizeHintFromDockWidgetMinimumSize
Definition dockwidget.h:94
void featuresChanged(DockWidget::DockWidgetFeatures features)
void visibilityChanged(bool visible)
This signal is emitted when the dock widget becomes visible (or invisible).
void topLevelChanged(bool topLevel)
This signal is emitted when the floating property changes.
The central dock window that maintains the complete docking system.
Definition dockwindow.h:36
DockSideBarArea
@ DockSideBarNone
#define QX_DECLARE_PRIVATE(Class)
#define QX_DOCK_END_NAMESPACE
#define QX_DOCK_BEGIN_NAMESPACE
#define QX_DOCK_EXPORT
QColor text
QColor window