summaryrefslogtreecommitdiffstats
path: root/src/widgets/widgets/qmainwindow.cpp
diff options
context:
space:
mode:
authorOlivier Goffart <ogoffart@woboq.com>2015-03-19 17:47:13 +0100
committerOlivier Goffart (Woboq GmbH) <ogoffart@woboq.com>2015-08-16 08:23:32 +0000
commitf029468b8d822da378a20577f7b8c16a447e4e1b (patch)
tree1880893f39f04e8ab95240671f2b4b7f381ad62d /src/widgets/widgets/qmainwindow.cpp
parent385202c27caa070e07eba098a1b968f9d466aaad (diff)
Add QMainWindow::resizeDocks
This API allows to programatically resize QDockWidgets Task-number: QTBUG-32001 Change-Id: I58072a391f8e7f325a26745b5bedd3fe49508e91 Reviewed-by: Jocelyn Turcotte (Woboq GmbH) <jturcotte@woboq.com>
Diffstat (limited to 'src/widgets/widgets/qmainwindow.cpp')
-rw-r--r--src/widgets/widgets/qmainwindow.cpp29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/widgets/widgets/qmainwindow.cpp b/src/widgets/widgets/qmainwindow.cpp
index 5d53e7def4..ff4bb3cc98 100644
--- a/src/widgets/widgets/qmainwindow.cpp
+++ b/src/widgets/widgets/qmainwindow.cpp
@@ -1237,6 +1237,35 @@ void QMainWindow::removeDockWidget(QDockWidget *dockwidget)
Qt::DockWidgetArea QMainWindow::dockWidgetArea(QDockWidget *dockwidget) const
{ return d_func()->layout->dockWidgetArea(dockwidget); }
+
+/*!
+ \since 5.6
+ Resizes the dock widgets in the list \a docks to the corresponding size in
+ pixels from the list \a sizes. If \a orientation is Qt::Horizontal, adjusts
+ the width, otherwise adjusts the height of the dock widgets.
+ The sizes will be adjusted such that the maximum and the minimum sizes are
+ respected and the QMainWindow itself will not be resized.
+ Any additional/missing space is distributed amongst the widgets according
+ to the relative weight of the sizes.
+
+ Example:
+ \code
+ resizeDocks({blueWidget, yellowWidget}, {20 , 40}, Qt::Horizontal);
+ \endcode
+ If the blue and the yellow widget are nested on the same level they will be
+ resized such that the yellowWidget is twice as big as the blueWidget
+
+ If some widgets are grouped in tabs, only one widget per group should be
+ specified. Widgets not in the list might be changed to repect the constraints.
+*/
+void QMainWindow::resizeDocks(const QList<QDockWidget *> &docks,
+ const QList<int> &sizes, Qt::Orientation orientation)
+{
+ d_func()->layout->layoutState.dockAreaLayout.resizeDocks(docks, sizes, orientation);
+ d_func()->layout->invalidate();
+}
+
+
#endif // QT_NO_DOCKWIDGET
/*!