QDockWidget improvements in Qt 5.6
We made some improvements to QDockWidget for Qt 5.6. You can now re-order your QDockWidget's tabs with the mouse. There is also a new mode you can set on your QMainWindow so that you can drag and drop full groups of tabbed QDockWidgets. Furthermore there is a new API which allows you to programatically resize the QDockWidgets.
Images (or in this case, animations) are worth a 1000 words:
Re-order the tabbed QDockWidgets:
This change applies to all the application using QDockWidget without any modification of their code.
New QMainwindow mode to drag tab by group
This is not by default because it changes the behaviour, so application developer may want to
enable
QMainWindow::GroupedDragging
in their code:
MyMainWindow::MyMainWindow(/*...*/) : QMainWindow(/*...*/) { /*...*/ setDockOptions(dockOptions() | QMainWindow::GroupedDragging); }
Without this flag, the user can only drag the QDockWidget's one by one. In this new mode, the user is able to drag the whole group of tabbed QDockWidget together by dragging the title. Individual QDockWidget can still be dragged by dragging the tab out of its tab bar.
This animation shows the example in qtbase/examples/widgets/mainwindows/mainwindow:
This changes the behaviour slightly as the QDockWidget may be reparented to an internal floating tab window. So if your application assumed that QDockWidget's parent was always the main window, it needs to be changed.
Programatically resize your dock widgets
If you want to give a default layout that looks nice for your application using many
QDockWidget, you can use QMainWindow::resizeDocks
to achieve that goal.
Conclusion
You can try these changes in the Qt 5.6 beta
We made those changes because it was requested by one of our customers. You can hire Woboq to fix your own Qt bugs or implement new features inside Qt. Send us an email with the bug number or a description of your feature, and we will reply with a quote.
QtWidgets still have their place on desktop and many applications are still using QDockWidgets.
Woboq is a software company that specializes in development and consulting around Qt and C++. Hire us!
If you like this blog and want to read similar articles, consider subscribing via our RSS feed (Via Google Feedburner, Privacy Policy), by e-mail (Via Google Feedburner, Privacy Policy) or follow us on twitter or add us on G+.
Article posted by Olivier Goffart on 18 December 2015
Click to subscribe via RSS or e-mail on Google Feedburner. (external service).
Click for the privacy policy of Google Feedburner.
Google Analytics Tracking Opt-Out
Loading comments embeds an external widget from disqus.com.
Check disqus privacy policy for more information.