Details
-
Bug
-
Resolution: Fixed
-
P2: Important
-
5.15.9, 6.5.0
-
None
-
-
e6e210c24 (dev), 34167f662 (6.9), b4dd1ac67 (6.8)
Description
In a QMdiArea instance with a TabbedView mode, movable and closable tabs, and multiple tabs (3 or more) after moving the tab (by dragging the user or via QTabBar::moveTab) the following is observed:
- after closing the current moved tab (without switching to others), all tabs are minimized without switching to the next one (seems like SubWindowView mode).
- after moving the tab and deactivating the application (for example, minimizing the application), and then further activation, it automatically switches to the tab with the old index.
I have my own workaround with connecting private header (private/qmdiarea_p.h): updating indicesToActivatedChildren:
connect(findChild<QTabBar*>(), &QTabBar::tabMoved, this, [this](int from, int to) { if (auto d = dynamic_cast<QMdiAreaPrivate*>(qGetPtrHelper(d_ptr))) { auto& indiciesActivatedSeq = d->indicesToActivatedChildren; if (int size = indiciesActivatedSeq.size(); from >= 0 && from < size && to >= 0 && to < size) { bool forward = from < to; int step = forward ? 1 : -1; std::function<bool(int, int)> comp = forward ? std::function(std::less_equal<int>()) : std::function(std::greater_equal<int>()); const int fromIndex = indiciesActivatedSeq.indexOf(from); indiciesActivatedSeq[fromIndex] = -1; for (int i = from + step; comp(i, to); i += step) indiciesActivatedSeq[indiciesActivatedSeq.indexOf(i)] -= step; indiciesActivatedSeq[fromIndex] = to; } } });
Perhaps some of this code can be added to QMdiAreaPrivate::_q_moveTab