summaryrefslogtreecommitdiffstats
path: root/src/widgets/widgets/qmainwindow.cpp
diff options
context:
space:
mode:
authorSune Vuorela <sune@vuorela.dk>2013-09-16 23:54:21 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-09-20 11:54:13 +0200
commite24f75af4db89ebdfd3d48e9d007238a1b990cd2 (patch)
treea2cd5345e259fdd2ab8156ddfa02e7b929f3dbc7 /src/widgets/widgets/qmainwindow.cpp
parent938c838c1019a21f22c8f238852084969a3d0682 (diff)
Implement QMainWindow::takeCentralWidget()
This allows the application developer to restructure the application, including moving the central widget some place else. Change-Id: Idca2f74c190500db24404e020b0eb400e41aad10 Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Diffstat (limited to 'src/widgets/widgets/qmainwindow.cpp')
-rw-r--r--src/widgets/widgets/qmainwindow.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/widgets/widgets/qmainwindow.cpp b/src/widgets/widgets/qmainwindow.cpp
index 436fb65dd2..0df83189ba 100644
--- a/src/widgets/widgets/qmainwindow.cpp
+++ b/src/widgets/widgets/qmainwindow.cpp
@@ -629,6 +629,22 @@ void QMainWindow::setCentralWidget(QWidget *widget)
d->layout->setCentralWidget(widget);
}
+/*!
+ Removes the central widget from this main window.
+
+ The ownership of the removed widget is passed to the caller.
+
+ \since Qt 5.2
+*/
+QWidget *QMainWindow::takeCentralWidget()
+{
+ Q_D(QMainWindow);
+ QWidget *oldcentralwidget = d->layout->centralWidget();
+ oldcentralwidget->setParent(0);
+ d->layout->setCentralWidget(0);
+ return oldcentralwidget;
+}
+
#ifndef QT_NO_DOCKWIDGET
/*!
Sets the given dock widget \a area to occupy the specified \a