Details
-
Suggestion
-
Resolution: Unresolved
-
Not Evaluated
-
None
-
6.4.3
-
None
Description
With QMdiArea in tabbed mode calling subWindowList with ANY of the 3 currently available WindowOrder enum values returns a list which does NOT represent the tab order itself. In order to persist the tab order and re open tabs in EXACLY the same positions with the same ACTIVE TAB it appears that it's currently necessary to DIVE into the internals of the QMdiArea which is something that makes me frown slightly. Furthermore with movable and closable tabs there is no appropriate notification signal - particularly for a move!!
I would suggest adding a tabOrder enum value and a tabPositionsChanged notification or something similar.
For now I suppose I'll find the child TabWidget and connect to its signals and obtain the window list in tab order that way!!
UPDATE
APOLOGIES (after scrutinisation of QMdiArea source code) - we don't need a new enum value!!!!
Actually QMdiArea::CreationOrder list the tabs in tab order!!!
BUT it's slightly counterintuitive since the order of the tabs is NOT necessarily the creation order.
Clearly if you want to track the REAL creation order its possible to do so BUT the documentation doesn't mention that CreationOrder isn't actually the true creation order.
I feel that the documentation should mention this!
HOWEVER in order to track changes to the tab order itself for which there is no direct notification signal (as mentioned in first para) its necessary to get hold of the inner QTabBar object
e.g.
QTabBar *tabBar = centralWidget_->findChild<QTabBar *>(); // centralWidget_ is a QMdiArea if (tabBar) { connect(tabBar, &QTabBar::currentChanged, this, [=](int index) { // save state }); }
which will successfully give you a notification of tab activation and changes to tab order by drag drop
For closing of sub windows its necessary to hook the destroy of sub windows individually (this is because you can close a sub window tab without activating it)
WHICH is why it might be simpler if there was simply a notification of the change to tab order which would mean it was not necessary to presume that there is an inner QTabBar object.