Skip to content

Commit 3c4af9c

Browse files
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.
1 parent 12ec819 commit 3c4af9c

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

src/DockManager.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -823,6 +823,16 @@ CDockAreaWidget* CDockManager::addDockWidget(DockWidgetArea area,
823823
return AreaOfAddedDockWidget;
824824
}
825825

826+
//============================================================================
827+
CDockAreaWidget* CDockManager::addDockWidgetToContainer(DockWidgetArea area,
828+
CDockWidget* Dockwidget, CDockContainerWidget* DockContainerWidget)
829+
{
830+
d->DockWidgetsMap.insert(Dockwidget->objectName(), Dockwidget);
831+
auto AreaOfAddedDockWidget = DockContainerWidget->addDockWidget(area, Dockwidget);
832+
Q_EMIT dockWidgetAdded(Dockwidget);
833+
return AreaOfAddedDockWidget;
834+
}
835+
826836

827837
//============================================================================
828838
CDockAreaWidget* CDockManager::addDockWidgetTab(DockWidgetArea area,

src/DockManager.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,15 @@ class ADS_EXPORT CDockManager : public CDockContainerWidget
283283
CDockAreaWidget* addDockWidget(DockWidgetArea area, CDockWidget* Dockwidget,
284284
CDockAreaWidget* DockAreaWidget = nullptr);
285285

286+
/**
287+
* Adds dockwidget into the given container.
288+
* This allows you to place the dock widget into a container, even if that
289+
* container does not yet contain a DockAreaWidget.
290+
* \return Returns the dock area widget that contains the new DockWidget
291+
*/
292+
CDockAreaWidget* addDockWidgetToContainer(DockWidgetArea area, CDockWidget* Dockwidget,
293+
CDockContainerWidget* DockContainerWidget);
294+
286295
/**
287296
* This function will add the given Dockwidget to the given dock area as
288297
* a new tab.

0 commit comments

Comments
 (0)