summaryrefslogtreecommitdiffstats
path: root/src/widgets/widgets/qmainwindow.cpp
diff options
context:
space:
mode:
authorFriedemann Kleint <Friedemann.Kleint@theqtcompany.com>2015-07-10 11:39:17 +0200
committerFriedemann Kleint <Friedemann.Kleint@theqtcompany.com>2015-07-13 10:18:40 +0000
commitb693900da5748277e34b99e37fd51f18861e03c4 (patch)
tree38bf129a813bdb4bc19c615fbbb84e636937b509 /src/widgets/widgets/qmainwindow.cpp
parent554d54b432bbbe8531b7bf4d8fc519280e679597 (diff)
Polish the widgets/mainwindows/application example.
- Introduce Qt 5 signals & slot syntax - Use QCommandLineParser to obtain file arguments - Merge MainWindow::createMenus()/createQToolBars() into MainWindow::createActions(), removing the need to store the actions as member variables. Use QMenu::addAction() for brevity. - Use QIcon::fromTheme() to obtain system icons and use resource icons as fallback. - Rewrite settings code to use QWidget::saveGeometry(), Widget::restoreGeometry() since saving size and position does not work well with multiple screens. Query the available size when determining the initial size instead of using hard-coded values for High-DPI screens. - Fix minor issues in code, use multi-argument version of QString::arg(), QDir::toNativeSeparators() to present file paths to the user. - Fix snippet references accordingly. Change-Id: I1bc49a8913aa6d669e0e666f04be3f1f42eaba10 Reviewed-by: Leena Miettinen <riitta-leena.miettinen@theqtcompany.com> Reviewed-by: Topi Reiniƶ <topi.reinio@digia.com>
Diffstat (limited to 'src/widgets/widgets/qmainwindow.cpp')
-rw-r--r--src/widgets/widgets/qmainwindow.cpp16
1 files changed, 14 insertions, 2 deletions
diff --git a/src/widgets/widgets/qmainwindow.cpp b/src/widgets/widgets/qmainwindow.cpp
index 935177867d..5d53e7def4 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