From 4e8adb4b7bfcd9892aaea0a7451d0c241be861d6 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Sun, 5 Jul 2015 17:05:23 +0200 Subject: [PATCH] QMainWindow: Remove dockwidgets from the floating tabs when plugging Example on how to reproduce the bug with examples/widgets/mainwindows/mainwindow: - Select the option "Groupped Dragging" from the "Main window" menu - Drag and drop dock widget so there are at least three of them in the same group of tabs (for example red, black, and green) - Drag the tab bar of one of them outside to make it floating (for example black) - Drag away the group of two remaining tabs to make them floating - Drack back the floating-alone (black) dock widget somewhere back inside the main window. => The black dock widget is tabbed with the other instead of being where we put it That's because it was still inactive (skipped) in the tab group. Task-number: QTBUG-47209 Change-Id: I84ac33d4ca1df0381c6007486b41830bd7be99a8 Reviewed-by: Paul Olav Tvete --- src/widgets/widgets/qmainwindowlayout.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/widgets/widgets/qmainwindowlayout.cpp b/src/widgets/widgets/qmainwindowlayout.cpp index d208cddc88b..aa2cf5c999d 100644 --- a/src/widgets/widgets/qmainwindowlayout.cpp +++ b/src/widgets/widgets/qmainwindowlayout.cpp @@ -1941,6 +1941,16 @@ bool QMainWindowLayout::plug(QLayoutItem *widgetItem) QWidget *widget = widgetItem->widget(); +#ifndef QT_NO_DOCKWIDGET + // Let's remove the widget from any possible group window + foreach (QDockWidgetGroupWindow *dwgw, + parent()->findChildren(QString(), Qt::FindDirectChildrenOnly)) { + QList path = dwgw->layoutInfo()->indexOf(widget); + if (!path.isEmpty()) + dwgw->layoutInfo()->remove(path); + } +#endif + QList previousPath = layoutState.indexOf(widget); const QLayoutItem *it = layoutState.plug(currentGapPos);