Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-112758

QMdiArea (in TabbedView mode): issues after moving tab

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 5.15.9, 6.5.0
    • None
    • Linux/X11, Windows

    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

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            mustafadjan Anton Mustafin
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes