From b693900da5748277e34b99e37fd51f18861e03c4 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Fri, 10 Jul 2015 11:39:17 +0200 Subject: Polish the widgets/mainwindows/application example. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 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 Reviewed-by: Topi Reiniƶ --- .../widgets/mainwindows/application/mainwindow.h | 21 ++------------------- 1 file changed, 2 insertions(+), 19 deletions(-) (limited to 'examples/widgets/mainwindows/application/mainwindow.h') diff --git a/examples/widgets/mainwindows/application/mainwindow.h b/examples/widgets/mainwindows/application/mainwindow.h index cb791abf00..08b4aa17f5 100644 --- a/examples/widgets/mainwindows/application/mainwindow.h +++ b/examples/widgets/mainwindows/application/mainwindow.h @@ -57,6 +57,8 @@ class MainWindow : public QMainWindow public: MainWindow(); + void loadFile(const QString &fileName); + protected: void closeEvent(QCloseEvent *event) Q_DECL_OVERRIDE; @@ -70,35 +72,16 @@ private slots: private: void createActions(); - void createMenus(); - void createToolBars(); void createStatusBar(); void readSettings(); void writeSettings(); bool maybeSave(); - void loadFile(const QString &fileName); bool saveFile(const QString &fileName); void setCurrentFile(const QString &fileName); QString strippedName(const QString &fullFileName); QPlainTextEdit *textEdit; QString curFile; - - QMenu *fileMenu; - QMenu *editMenu; - QMenu *helpMenu; - QToolBar *fileToolBar; - QToolBar *editToolBar; - QAction *newAct; - QAction *openAct; - QAction *saveAct; - QAction *saveAsAct; - QAction *exitAct; - QAction *cutAct; - QAction *copyAct; - QAction *pasteAct; - QAction *aboutAct; - QAction *aboutQtAct; }; //! [0] -- cgit v1.2.3