From 89dbd20e1df0a9d9700a8a2d12ca848bd2c9b09b Mon Sep 17 00:00:00 2001 From: Sergio Martins Date: Sun, 8 Dec 2019 17:24:30 +0000 Subject: [PATCH] Honour the widget's initial size when adding it to the layout In MultiSplitterLayout::lengthForDrop(), we use frame's size as the suggested size to use when add a dock widget. So give the frame the size of the dock widget. User can now do: dockwidget->resize(foo); mainwindow->addWidget(); and it will respect the size --- src/private/Frame.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/private/Frame.cpp b/src/private/Frame.cpp index 8f0a9b8a..7be83e84 100644 --- a/src/private/Frame.cpp +++ b/src/private/Frame.cpp @@ -144,6 +144,13 @@ void Frame::insertWidget(DockWidgetBase *dockWidget, int index) if (hasSingleDockWidget()) { Q_EMIT currentDockWidgetChanged(dockWidget); setObjectName(dockWidget->uniqueName()); + + if (!m_layoutItem) { + // When adding the 1st dock widget of a fresh frame, let's give the frame the size + // of the dock widget, so that when adding it to the main window, the main window can + // use that size as the initial suggested size. + resize(dockWidget->size()); + } } connect(dockWidget, &DockWidgetBase::titleChanged, this, &Frame::updateTitleAndIcon);