summaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
authorPaul Wicking <paul.wicking@qt.io>2018-06-13 13:04:10 +0200
committerPaul Wicking <paul.wicking@qt.io>2018-06-21 14:23:27 +0000
commitf415f50619ceedff05bcf97336cf05374130a2a7 (patch)
treecd0259257a22f0f52e72c8055bd003945eaf1a27 /examples
parent06996e1d0e90fa89d3f18456da91d80c9a6a95f8 (diff)
Doc: Add menu bar to Books example
Add menu bar with Help->About that contains a short description of the example application. Remove redundant title string between menu and application content. Task-number: QTBUG-68652 Change-Id: I31fb386ab9c01eff86b8ed3ef274ba8cfdb0148b Reviewed-by: Topi Reiniƶ <topi.reinio@qt.io>
Diffstat (limited to 'examples')
-rw-r--r--examples/sql/books/bookwindow.cpp26
-rw-r--r--examples/sql/books/bookwindow.h5
-rw-r--r--examples/sql/books/bookwindow.ui2
3 files changed, 32 insertions, 1 deletions
diff --git a/examples/sql/books/bookwindow.cpp b/examples/sql/books/bookwindow.cpp
index 3aac5b55b7..76f3c9da8f 100644
--- a/examples/sql/books/bookwindow.cpp
+++ b/examples/sql/books/bookwindow.cpp
@@ -136,6 +136,7 @@ BookWindow::BookWindow()
);
ui.bookTable->setCurrentIndex(model->index(0, 0));
+ createMenuBar();
}
void BookWindow::showError(const QSqlError &err)
@@ -143,3 +144,28 @@ void BookWindow::showError(const QSqlError &err)
QMessageBox::critical(this, "Unable to initialize Database",
"Error initializing database: " + err.text());
}
+
+void BookWindow::createMenuBar()
+{
+ QAction *quitAction = new QAction(tr("&Quit"), this);
+ QAction *aboutAction = new QAction(tr("&About"), this);
+ QAction *aboutQtAction = new QAction(tr("&About Qt"), this);
+
+ QMenu *fileMenu = menuBar()->addMenu(tr("&File"));
+ fileMenu->addAction(quitAction);
+
+ QMenu *helpMenu = menuBar()->addMenu(tr("&Help"));
+ helpMenu->addAction(aboutAction);
+ helpMenu->addAction(aboutQtAction);
+
+ connect(quitAction, &QAction::triggered, this, &BookWindow::close);
+ connect(aboutAction, &QAction::triggered, this, &BookWindow::about);
+ connect(aboutQtAction, &QAction::triggered, qApp, &QApplication::aboutQt);
+}
+
+void BookWindow::about()
+{
+ QMessageBox::about(this, tr("About Books"),
+ tr("<p>The <b>Books</b> example shows how to use Qt SQL classes "
+ "with a model/view framework."));
+}
diff --git a/examples/sql/books/bookwindow.h b/examples/sql/books/bookwindow.h
index 4b2be0e729..ec6b935242 100644
--- a/examples/sql/books/bookwindow.h
+++ b/examples/sql/books/bookwindow.h
@@ -63,11 +63,16 @@ class BookWindow: public QMainWindow
public:
BookWindow();
+private slots:
+ void about();
+
private:
void showError(const QSqlError &err);
Ui::BookWindow ui;
QSqlRelationalTableModel *model;
int authorIdx, genreIdx;
+
+ void createMenuBar();
};
#endif
diff --git a/examples/sql/books/bookwindow.ui b/examples/sql/books/bookwindow.ui
index c81a86cb2c..ce8f9f933a 100644
--- a/examples/sql/books/bookwindow.ui
+++ b/examples/sql/books/bookwindow.ui
@@ -33,7 +33,7 @@
<item>
<widget class="QGroupBox" name="groupBox">
<property name="title">
- <string>Books</string>
+ <string/>
</property>
<layout class="QVBoxLayout">
<property name="spacing">