Add method to add dock widget to dock container (#398)

This adds a `addDockWidgetToContainer()` method to `CDockManager`, which allows a dock widget to be registered with the dock manager, and added to a specific container, even if that container doesn't currently have any `DockAreaWidget`s.

This is pretty much just a clone of `addDockWidget()`, but with the ability to specify a container widget instead of a dock area.
This commit is contained in:
Ben Hetherington 2022-02-06 07:21:43 +00:00 committed by GitHub
parent 12ec819aeb
commit 3c4af9c6af
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 19 additions and 0 deletions

View File

@ -823,6 +823,16 @@ CDockAreaWidget* CDockManager::addDockWidget(DockWidgetArea area,
return AreaOfAddedDockWidget;
}
//============================================================================
CDockAreaWidget* CDockManager::addDockWidgetToContainer(DockWidgetArea area,
CDockWidget* Dockwidget, CDockContainerWidget* DockContainerWidget)
{
d->DockWidgetsMap.insert(Dockwidget->objectName(), Dockwidget);
auto AreaOfAddedDockWidget = DockContainerWidget->addDockWidget(area, Dockwidget);
Q_EMIT dockWidgetAdded(Dockwidget);
return AreaOfAddedDockWidget;
}
//============================================================================
CDockAreaWidget* CDockManager::addDockWidgetTab(DockWidgetArea area,

View File

@ -283,6 +283,15 @@ public:
CDockAreaWidget* addDockWidget(DockWidgetArea area, CDockWidget* Dockwidget,
CDockAreaWidget* DockAreaWidget = nullptr);
/**
* Adds dockwidget into the given container.
* This allows you to place the dock widget into a container, even if that
* container does not yet contain a DockAreaWidget.
* \return Returns the dock area widget that contains the new DockWidget
*/
CDockAreaWidget* addDockWidgetToContainer(DockWidgetArea area, CDockWidget* Dockwidget,
CDockContainerWidget* DockContainerWidget);
/**
* This function will add the given Dockwidget to the given dock area as
* a new tab.