Skip to content

Commit 46fa22d

Browse files
Documented custom close handling
1 parent f3d3239 commit 46fa22d

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

doc/user-guide.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
- [`FloatingContainerForceNativeTitleBar` (Linux only)](#floatingcontainerforcenativetitlebar-linux-only)
2929
- [`FloatingContainerForceQWidgetTitleBar` (Linux only)](#floatingcontainerforceqwidgettitlebar-linux-only)
3030
- [Central Widget](#central-widget)
31+
- [Custom Close Handling](#custom-close-handling)
3132
- [Styling](#styling)
3233
- [Disabling the Internal Style Sheet](#disabling-the-internal-style-sheet)
3334

@@ -499,6 +500,11 @@ See the `centralwidget` example to learn how it works.
499500
> are already other dock widgets registered. So `setCentralWidget` should be
500501
> the first function that you call when adding dock widgets.
501502
503+
## Custom Close Handling
504+
505+
Normally clicking the close button of a dock widget will just hide the widget and the user can show it again using the `toggleView()` action of the dock widget. This is meant for user interfaces with a static amount of widgets. But the advanced docking system also supports dynamic dock widgets that will get deleted on close. If you set the dock widget flag `DockWidgetDeleteOnClose` for a certain dock widget, then it will be deleted as soon as you close this dock widget. This enables the implementation of user interfaces with dynamically created editors, like in word processing applications or source code development tools.
506+
507+
When an entire area is closed, the default behavior is to hide the dock widgets it contains regardless of the `DockWidgetDeleteOnClose` flag except if there is only one dock widget. In this special case, the `DockWidgetDeleteOnClose` flag is followed. This behavior can be changed by setting the `DockWidgetForceCloseWithArea` flag to all the dock widgets that needs to be closed with their area.
502508

503509
## Styling
504510

src/DockWidget.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,10 @@ private slots:
153153
DockWidgetDeleteOnClose = 0x08, ///< deletes the dock widget when it is closed
154154
CustomCloseHandling = 0x10, ///< clicking the close button will not close the dock widget but emits the closeRequested() signal instead
155155
DockWidgetFocusable = 0x20, ///< if this is enabled, a dock widget can get focus highlighting
156-
DockWidgetForceCloseWithArea = 0x40,
156+
DockWidgetForceCloseWithArea = 0x40, ///< dock widget will be closed when the dock area hosting it is closed
157157
DefaultDockWidgetFeatures = DockWidgetClosable | DockWidgetMovable | DockWidgetFloatable | DockWidgetFocusable,
158158
AllDockWidgetFeatures = DefaultDockWidgetFeatures | DockWidgetDeleteOnClose | CustomCloseHandling,
159+
DockWidgetAlwaysCloseAndDelete = DockWidgetForceCloseWithArea | DockWidgetDeleteOnClose,
159160
NoDockWidgetFeatures = 0x00
160161
};
161162
Q_DECLARE_FLAGS(DockWidgetFeatures, DockWidgetFeature)

0 commit comments

Comments
 (0)