From b9b8ff9c76aaa606e372f2ac258314390ac3bfe0 Mon Sep 17 00:00:00 2001 From: Tibo Clausen Date: Thu, 16 May 2019 11:53:31 +0100 Subject: [PATCH] Add CDockWidget::releaseWidget() --- src/DockWidget.cpp | 9 +++++++++ src/DockWidget.h | 5 +++++ 2 files changed, 14 insertions(+) diff --git a/src/DockWidget.cpp b/src/DockWidget.cpp index c8ca3bb..e901808 100644 --- a/src/DockWidget.cpp +++ b/src/DockWidget.cpp @@ -262,6 +262,15 @@ void CDockWidget::setWidget(QWidget* widget, eInsertMode InsertMode) } +//============================================================================ +void CDockWidget::releaseWidget() +{ + d->ScrollArea->takeWidget(); + d->Layout->removeWidget(d->Widget); + d->Widget->setParent(nullptr); +} + + //============================================================================ QWidget* CDockWidget::widget() const { diff --git a/src/DockWidget.h b/src/DockWidget.h index e083137..3decfc6 100644 --- a/src/DockWidget.h +++ b/src/DockWidget.h @@ -238,6 +238,11 @@ public: */ void setWidget(QWidget* widget, eInsertMode InsertMode = AutoScrollArea); + /** + * Remove the widget from the dock and give ownership back to the caller + */ + void releaseWidget(); + /** * Returns the widget for the dock widget. This function returns zero if * the widget has not been set.