I'm developing on a project that needs an interface with support of floating tabs similar to the ones in Visual Studio (as is shown below).
The interface is expected to provide the following features:
- Several sub-windows are in the main window and can be added, removed or moved to another place;
- When several sub-windows occupy the same space, they appear as several tabs;
- Users can drag & drop the sub-windows (tabs) to move them to another place;
- As the sub-windows are dragged beside one of the sides of the main window, they can be automatically docked to the side;
- When a sub-window (tab) is not docked to any of the sides, it appears as a standalone window and can be located out of the range of the main window (to support multiple monitors).
So how can I implement such a VS-like window manager (if it is called so)? I am familiar with C++ and Qt and plan to implement such features with Qt.
I've tried two of the choices Qt provides to me, but both in vain:
- I tried building a MDI application with Qt. I tried the official MDI example and found some problems:
- The sub-windows are not automatically docked;
- The sub-windows are not turning to tabs when they occupy the same space;
- The sub-windows cannot be located out of the range of the main window.
- I also tried using the dock widgets (mainly
QDockWidget
). I tried the official dock widgets example and also found some problems:- The central widget is useless, but once it is removed (programmatically, with answer in this question) the auto-docking feature seems broken;
- The sub-windows can only be docked to one of the sides. For example, I cannot create 4x4 sub-windows in a main window.
So how can I implement such features with Qt and C++? Is there a handy solution provided by Qt, or do I have to implement these manually (by listening to the mouse events and set the correpsonding sub-windows)?
Thanks in advance!