diff options
author | Friedemann Kleint <Friedemann.Kleint@theqtcompany.com> | 2015-07-15 13:29:31 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@theqtcompany.com> | 2015-07-17 14:14:56 +0000 |
commit | fdb8ef6507a556589425e7a109172952c03bfd22 (patch) | |
tree | 94ed3819df813c5d27971dc6e6bd4271f9cddb48 /examples/widgets/mainwindows/sdi/mainwindow.h | |
parent | 696ea2fff15cf0f8c1016353cfcb93d1f368129c (diff) |
Polish the widgets/mainwindows/sdi example.
- Introduce Qt 5 signals & slot syntax.
- Use QCommandLineParser to obtain file arguments, factor
out positioning into tile() function to be able to
use it from command line and open/new slots.
- 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 and and static method invocation.
- Fix snippet references accordingly.
Change-Id: I3ea0372bc7ff82247192f54620289352fb68d60f
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
Diffstat (limited to 'examples/widgets/mainwindows/sdi/mainwindow.h')
-rw-r--r-- | examples/widgets/mainwindows/sdi/mainwindow.h | 28 |
1 files changed, 6 insertions, 22 deletions
diff --git a/examples/widgets/mainwindows/sdi/mainwindow.h b/examples/widgets/mainwindows/sdi/mainwindow.h index f1860a8511..3c01f38566 100644 --- a/examples/widgets/mainwindows/sdi/mainwindow.h +++ b/examples/widgets/mainwindows/sdi/mainwindow.h @@ -42,6 +42,7 @@ #define MAINWINDOW_H #include <QMainWindow> +#include <QList> QT_BEGIN_NAMESPACE class QAction; @@ -57,7 +58,9 @@ class MainWindow : public QMainWindow public: MainWindow(); //! [class definition with macro] - MainWindow(const QString &fileName); + explicit MainWindow(const QString &fileName); + + void tile(const QMainWindow *previous); protected: void closeEvent(QCloseEvent *event) Q_DECL_OVERRIDE; @@ -73,8 +76,6 @@ private slots: private: void init(); void createActions(); - void createMenus(); - void createToolBars(); void createStatusBar(); void readSettings(); void writeSettings(); @@ -82,29 +83,12 @@ private: void loadFile(const QString &fileName); bool saveFile(const QString &fileName); void setCurrentFile(const QString &fileName); - QString strippedName(const QString &fullFileName); - MainWindow *findMainWindow(const QString &fileName); + static QString strippedName(const QString &fullFileName); + MainWindow *findMainWindow(const QString &fileName) const; QTextEdit *textEdit; QString curFile; bool isUntitled; - - QMenu *fileMenu; - QMenu *editMenu; - QMenu *helpMenu; - QToolBar *fileToolBar; - QToolBar *editToolBar; - QAction *newAct; - QAction *openAct; - QAction *saveAct; - QAction *saveAsAct; - QAction *closeAct; - QAction *exitAct; - QAction *cutAct; - QAction *copyAct; - QAction *pasteAct; - QAction *aboutAct; - QAction *aboutQtAct; }; #endif |