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
This commit is contained in:
Sergio Martins
2019-12-08 17:24:30 +00:00
parent 7bb0a29aea
commit 89dbd20e1d

View File

@@ -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);