I see that QMdiArea has a tabbed view mode. I want to be able to split the main window with two QMdiArea widgets and to be able to drag and drop tabs between each of them.
I have already done it with a simple QTabWidget where I can set custom tab bar. At the same time I want to switch QMdiArea view mode thus using QTabWidget is not an option for me. But I don't see any methods to set custom tab bar within QMdiArea.
How can this be done?
Answer provided by Dmitry K.
You have to make a new class inheriting
QMdiArea. Set its view mode toTabbedViewto make the standardQTabBarto be constructed withinQMdiArea. Then get all children and findQTabBarwidget withQString(QObject::metaObject()->className()) == "QTabBar". Hide it. You will get a blank area above the document inTabbedViewmode. Construct you custom tab bar and reparent it to your custom mdi area. Connect signals and slots that are fired and used when the sub windows and tabs are activated. You can have your custom tab bar as a class member of your custom mdi area.Code example:
Looking for a standart
QTabBarwithin a custom mdi area in its constructor:Reparent:
Hiding:
Signals & Slots used:
QMdiArea::subWindowActivated(QMdiSubWindow*),QTabBar::currentChanged(int)