summaryrefslogtreecommitdiffstats
path: root/examples/sql/books/bookwindow.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'examples/sql/books/bookwindow.cpp')
-rw-r--r--examples/sql/books/bookwindow.cpp26
1 files changed, 26 insertions, 0 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."));
+}