diff options
Diffstat (limited to 'src/widgets/widgets/qmainwindow.cpp')
-rw-r--r-- | src/widgets/widgets/qmainwindow.cpp | 54 |
1 files changed, 51 insertions, 3 deletions
diff --git a/src/widgets/widgets/qmainwindow.cpp b/src/widgets/widgets/qmainwindow.cpp index 4d5d3e5ec1..ff4bb3cc98 100644 --- a/src/widgets/widgets/qmainwindow.cpp +++ b/src/widgets/widgets/qmainwindow.cpp @@ -263,7 +263,14 @@ void QMainWindowPrivate::init() An example of how to create menus follows: - \snippet mainwindows/application/mainwindow.cpp 26 + \code + void MainWindow::createMenus() + { + fileMenu = menuBar()->addMenu(tr("&File")); + fileMenu->addAction(newAct); + fileMenu->addAction(openAct); + fileMenu->addAction(saveAct); + \endcode The \c createPopupMenu() function creates popup menus when the main window receives context menu events. The default @@ -290,7 +297,12 @@ void QMainWindowPrivate::init() An example of toolbar creation follows: - \snippet mainwindows/application/mainwindow.cpp 29 + \code + void MainWindow::createToolBars() + { + fileToolBar = addToolBar(tr("File")); + fileToolBar->addAction(newAct); + \endcode \section2 Creating Dock Widgets @@ -420,6 +432,13 @@ QMainWindow::~QMainWindow() at the bottom. Implies AllowTabbedDocks. See also \l setTabPosition(). + \value GroupedDragging When dragging the titlebar of a dock, all the tabs + that are tabbed with it are going to be dragged. + Implies AllowTabbedDocks. Does not work well if + some QDockWidgets have restrictions in which area + they are allowed. (This enum value was added in Qt + 5.6.) + These options only control how dock widgets may be dropped in a QMainWindow. They do not re-arrange the dock widgets to conform with the specified options. For this reason they should be set before any dock widgets @@ -1080,7 +1099,7 @@ void QMainWindow::addDockWidget(Qt::DockWidgetArea area, QDockWidget *dockwidget addDockWidget(area, dockwidget, orientation); #ifdef Q_DEAD_CODE_FROM_QT4_MAC //drawer support - QMacCocoaAutoReleasePool pool; + QMacAutoReleasePool pool; extern bool qt_mac_is_macdrawer(const QWidget *); //qwidget_mac.cpp if (qt_mac_is_macdrawer(dockwidget)) { extern bool qt_mac_set_drawer_preferred_edge(QWidget *, Qt::DockWidgetArea); //qwidget_mac.cpp @@ -1218,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 /*! |