diff options
author | Christian Ehrlicher <ch.ehrlicher@gmx.de> | 2018-11-12 21:20:34 +0100 |
---|---|---|
committer | Christian Ehrlicher <ch.ehrlicher@gmx.de> | 2018-12-04 07:00:41 +0000 |
commit | 51f6d5d8c261fb94adc9bf5754cabf8e37236af5 (patch) | |
tree | 88a374c564ffadd6b1f90e97121ab7274484bf71 /examples/widgets/itemviews/addressbook/mainwindow.cpp | |
parent | 8c38b08343b226883ef368d31a085b0a620f7995 (diff) |
Cleanup Addressbook example
Cleanup the Addressbook example:
- use nullptr
- use for instead foreach
- don't use public members but setters/getters
- use QVector instead QList
- make user-visible translatable
Change-Id: Ie7bdad8a2799c8fa6f634659b51c3064cc8a04ce
Reviewed-by: Samuel Gaist <samuel.gaist@idiap.ch>
Reviewed-by: Sze Howe Koh <szehowe.koh@gmail.com>
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
Reviewed-by: Luca Beldi <v.ronin@yahoo.it>
Diffstat (limited to 'examples/widgets/itemviews/addressbook/mainwindow.cpp')
-rw-r--r-- | examples/widgets/itemviews/addressbook/mainwindow.cpp | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/examples/widgets/itemviews/addressbook/mainwindow.cpp b/examples/widgets/itemviews/addressbook/mainwindow.cpp index 6d8b15b032..42966de375 100644 --- a/examples/widgets/itemviews/addressbook/mainwindow.cpp +++ b/examples/widgets/itemviews/addressbook/mainwindow.cpp @@ -56,8 +56,9 @@ //! [0] MainWindow::MainWindow() + : QMainWindow(), + addressWidget(new AddressWidget) { - addressWidget = new AddressWidget; setCentralWidget(addressWidget); createMenus(); setWindowTitle(tr("Address Book")); @@ -67,28 +68,29 @@ MainWindow::MainWindow() //! [1a] void MainWindow::createMenus() { - fileMenu = menuBar()->addMenu(tr("&File")); + QMenu *fileMenu = menuBar()->addMenu(tr("&File")); - openAct = new QAction(tr("&Open..."), this); + QAction *openAct = new QAction(tr("&Open..."), this); fileMenu->addAction(openAct); connect(openAct, &QAction::triggered, this, &MainWindow::openFile); //! [1a] - saveAct = new QAction(tr("&Save As..."), this); + QAction *saveAct = new QAction(tr("&Save As..."), this); fileMenu->addAction(saveAct); connect(saveAct, &QAction::triggered, this, &MainWindow::saveFile); fileMenu->addSeparator(); - exitAct = new QAction(tr("E&xit"), this); + QAction *exitAct = new QAction(tr("E&xit"), this); fileMenu->addAction(exitAct); connect(exitAct, &QAction::triggered, this, &QWidget::close); - toolMenu = menuBar()->addMenu(tr("&Tools")); + QMenu *toolMenu = menuBar()->addMenu(tr("&Tools")); - addAct = new QAction(tr("&Add Entry..."), this); + QAction *addAct = new QAction(tr("&Add Entry..."), this); toolMenu->addAction(addAct); - connect(addAct, &QAction::triggered, addressWidget, &AddressWidget::showAddEntryDialog); + connect(addAct, &QAction::triggered, + addressWidget, &AddressWidget::showAddEntryDialog); //! [1b] editAct = new QAction(tr("&Edit Entry..."), this); |