KDDockWidgets is an advanced docking system for Qt, with features that are not available in QDockWidget. See our first blog post, for a quick introduction and the motivation for a new docking framework.
What's new in 1.0?
We've come a long way since the initial announcement of KDDockWidgets. The 1.0 release represents the culmination of one year of using the library in production for five different huge projects -- one year of incorporating real feedback in the form of new features, bug fixes, or simply making the framework more customizable.
We could have tagged 1.0 much sooner, but I gain more personal satisfaction in calling the current state 1.0, as it's very stable and almost feature-complete. We're on the verge of stepping on the gas for the Qt Quick port, as there's very little to add to the Qt Widget API.
Read on, for a few of the highlights of the KDDockWidgets 1.0 release.
Quality
We now have 200 automated tests, accounting for 30% of the codebase. It took a lot of time to get there but now they actually save us time, catching regressions very soon.
We wrote a fuzzer, to test the example app randomly for hours until it crashes. All this with Address Sanitizer enabled so memory violations and leaks don't escape.
Rewritten layouting engine
For the KDDockWidgets 1.0 release, the layouting engine was factored out into its own reusable library without QWidget dependencies. This will allow sharing 5000 lines of code for the Qt Quick port right off the bat, but also benefits the QWidget codebase a lot, as the new engine is much more flexible. For instance, it was trivial to add support for max-size constraints and honour a bit of QSizePolicy.
Customizable docking indicators
Additionally, KDDW allows users to provide their own docking indicators. This is not just about changing icons or colors, the whole mechanism can be modified.
In the example below, we demonstrate how we created a new docking indicator type called "Segmented Indicators" in just a few hours.
Run kddockwidgets_example -y to see it in action.
MainWindows within MainWindows
You can now dock a main windowinto another main window, as if it were a dock widget. On top of that, you can even dock floating windows into the inner dock widget if that pleases you.
Not saying you should, but it's something many people asked. Sometimes, it's simply because they had this in MFC and wouldn't be able to complete a port to Qt without it.
In the example below, I show you the "affinity" concept. The yellow dock widgets can only be docked into the yellow main window, but this is optional. If you want, you can dock anything,anywhere.
Windows Aero-Snap
Aero-snap is the functionality which maximizes a window when you drag it near the screen's edges. Typically you loose this feature when using Qt::FramelessWindowHint , but that can be worked around.
For the KDDockWidgets 1.0 release, we even did many improvements for using Aero-snap with Windows with custom title bars. Expect some HDPI fixes for v1.1 too.
Reworked layout save/restore
Layout restoring is now done in two steps. First, everything is loaded and validated. Only if the validation passes do we change the GUI. Before, it was very hard to recover from an error if we were in the middle of the restore.
Save/restore now works better on different HDPI setups. We've added the RestoreOption_RelativeToMainWindow, which, when used, will restore the dock widgets in relation to the main window's size, instead of using absolute values which could have been saved in a different screen size.
More Config.h options
Config::flags() has 5 new options for tuning little details. They are:
Flag_AllowReorderTabs
Flag_TabsHaveCloseButton
Flag_DoubleClickMaximizes
Flag_TitleBarHasMaximizeButton
Flag_LazyResize
Consult the documentation for more information, but they are pretty self-explanatory :).
ChangeLog
Here is a more comprehensive list of features and improvements in the KDDockWidgets 1.0 release:
PySide2 bindings
Rewrote the layouting engine, resulting in a huge stability gain and makes it easy to add new features
Honour min/max sizes and some QSizePolicy heuristics
Lazy resize (resize only when dropping the separator)
Native Windows dragging (supporting Aero-snap) improvements
Reordering tabs with mouse
Partial layout save/restore (affecting only a subset)
Double-click on title bar to maximize
Optional maximize button on the title bar
HDPI: Restoring relative to main window size, instead of absolute geometries
Allow to make a dock widget non-closable and non-dockable
Show close button on tabs
Multiple Main Window support
Allowing to dock on different parents
Support for affinities, making some dock widgets only dockable on certain main windows
200 unit-tests
Fuzzer which found plenty of crashes in the old layouting engine
ASAN/UBSAN fixes
Double click on separator to distribute equally
Hovering over an indicator returns the true size that the dropped widget will get
Prebuilt packages for some popular Linux distributions can be found at: https://build.opensuse.org/project/repositories/isv:KDAB
Licensing options
For commercial licensing regarding inclusion in proprietary software and/or for tailored support options contact us and ask for a 30-day free trial license.
This blog uses KDDockWidgets as an example for creating Python bindings for your Qt Libraries. Give it a read if you're interested in that process.
Yes, widgets are still alive and kicking. In the many years we have worked with them, we have gathered quite a number of tips and tricks that we’d love to share with you.
The KDAB Group is a globally recognized provider for software consulting, development and training, specializing in embedded devices and complex cross-platform desktop applications. In addition to being leading experts in Qt, C++ and 3D technologies for over two decades, KDAB provides deep expertise across the stack, including Linux, Rust and modern UI frameworks. With 100+ employees from 20 countries and offices in Sweden, Germany, USA, France and UK, we serve clients around the world.
Sérgio Martins
Senior Software Engineer
Sérgio has been with KDAB for 13 years. He loves performance profiling, debugging, static-analysis, and tooling. You won’t see him writing nice-looking GUIs or 3D. He’d rather enjoy tackling a hard problem, frequently embracing the pain of bugs nobody wants, such as HDPI, fonts, QDockWidget, and even working on Windows when needed.