summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@qt.io>2023-02-20 11:18:35 +0100
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2023-02-20 15:51:07 +0000
commitefe740e03bd64a6f50f43cba06260c9d003e7605 (patch)
tree611c3195fa0fa9ce0c056ae778a59e551d361884 /examples
parent8bcf236daac1c5636a2cf535cf38d0b412265c8c (diff)
downloadqtbase-efe740e03bd64a6f50f43cba06260c9d003e7605.tar.gz
examples: Connect Quit action to QCoreApplication::quit, not QWidget::close
Change-Id: I44ca7b61a4a261a7d3aad0dfeb870eb927ee768d Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io> (cherry picked from commit 850ef55fc57e62b70bab72705038e671002ca86e) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'examples')
-rw-r--r--examples/network/broadcastreceiver/receiver.cpp3
-rw-r--r--examples/network/broadcastsender/sender.cpp2
-rw-r--r--examples/network/loopback/dialog.cpp2
-rw-r--r--examples/network/multicastreceiver/receiver.cpp2
-rw-r--r--examples/sql/books/bookwindow.cpp2
-rw-r--r--examples/sql/masterdetail/mainwindow.cpp2
-rw-r--r--examples/widgets/mainwindows/dockwidgets/mainwindow.cpp2
-rw-r--r--examples/widgets/mainwindows/mainwindow/mainwindow.cpp2
-rw-r--r--examples/widgets/richtext/textedit/textedit.cpp2
-rw-r--r--examples/widgets/widgets/icons/mainwindow.cpp2
10 files changed, 11 insertions, 10 deletions
diff --git a/examples/network/broadcastreceiver/receiver.cpp b/examples/network/broadcastreceiver/receiver.cpp
index caa05ac45a..ffade9992c 100644
--- a/examples/network/broadcastreceiver/receiver.cpp
+++ b/examples/network/broadcastreceiver/receiver.cpp
@@ -5,6 +5,7 @@
#include <QPushButton>
#include <QUdpSocket>
#include <QVBoxLayout>
+#include <QCoreApplication>
#include "receiver.h"
@@ -26,7 +27,7 @@ Receiver::Receiver(QWidget *parent)
this, &Receiver::processPendingDatagrams);
//! [1]
connect(quitButton, &QPushButton::clicked,
- this, &Receiver::close);
+ qApp, &QCoreApplication::quit);
auto buttonLayout = new QHBoxLayout;
buttonLayout->addStretch(1);
diff --git a/examples/network/broadcastsender/sender.cpp b/examples/network/broadcastsender/sender.cpp
index 7aa416ad6c..622d3f9616 100644
--- a/examples/network/broadcastsender/sender.cpp
+++ b/examples/network/broadcastsender/sender.cpp
@@ -25,7 +25,7 @@ Sender::Sender(QWidget *parent)
//! [0]
connect(startButton, &QPushButton::clicked, this, &Sender::startBroadcasting);
- connect(quitButton, &QPushButton::clicked, this, &Sender::close);
+ connect(quitButton, &QPushButton::clicked, qApp, &QCoreApplication::quit);
connect(&timer, &QTimer::timeout, this, &Sender::broadcastDatagram);
auto mainLayout = new QVBoxLayout;
diff --git a/examples/network/loopback/dialog.cpp b/examples/network/loopback/dialog.cpp
index d1673d3338..f2391fd5b8 100644
--- a/examples/network/loopback/dialog.cpp
+++ b/examples/network/loopback/dialog.cpp
@@ -25,7 +25,7 @@ Dialog::Dialog(QWidget *parent)
buttonBox->addButton(quitButton, QDialogButtonBox::RejectRole);
connect(startButton, &QAbstractButton::clicked, this, &Dialog::start);
- connect(quitButton, &QAbstractButton::clicked, this, &QWidget::close);
+ connect(quitButton, &QAbstractButton::clicked, qApp, &QCoreApplication::quit);
connect(&tcpServer, &QTcpServer::newConnection,
this, &Dialog::acceptConnection);
connect(&tcpClient, &QAbstractSocket::connected, this, &Dialog::startTransfer);
diff --git a/examples/network/multicastreceiver/receiver.cpp b/examples/network/multicastreceiver/receiver.cpp
index 2a49553875..0ebeed8316 100644
--- a/examples/network/multicastreceiver/receiver.cpp
+++ b/examples/network/multicastreceiver/receiver.cpp
@@ -38,7 +38,7 @@ Receiver::Receiver(QWidget *parent)
connect(&udpSocket6, &QUdpSocket::readyRead,
this, &Receiver::processPendingDatagrams);
connect(quitButton, &QPushButton::clicked,
- this, &Receiver::close);
+ qApp, &QCoreApplication::quit);
}
void Receiver::processPendingDatagrams()
diff --git a/examples/sql/books/bookwindow.cpp b/examples/sql/books/bookwindow.cpp
index 6ec1b9e19a..2ec5459e1b 100644
--- a/examples/sql/books/bookwindow.cpp
+++ b/examples/sql/books/bookwindow.cpp
@@ -111,7 +111,7 @@ void BookWindow::createMenuBar()
helpMenu->addAction(aboutAction);
helpMenu->addAction(aboutQtAction);
- connect(quitAction, &QAction::triggered, this, &BookWindow::close);
+ connect(quitAction, &QAction::triggered, qApp, &QCoreApplication::quit);
connect(aboutAction, &QAction::triggered, this, &BookWindow::about);
connect(aboutQtAction, &QAction::triggered, qApp, &QApplication::aboutQt);
}
diff --git a/examples/sql/masterdetail/mainwindow.cpp b/examples/sql/masterdetail/mainwindow.cpp
index 9e4fa415af..d720db1033 100644
--- a/examples/sql/masterdetail/mainwindow.cpp
+++ b/examples/sql/masterdetail/mainwindow.cpp
@@ -341,7 +341,7 @@ void MainWindow::createMenuBar()
connect(deleteAction, &QAction::triggered,
this, &MainWindow::deleteAlbum);
connect(quitAction, &QAction::triggered,
- this, &MainWindow::close);
+ qApp, &QCoreApplication::quit);
connect(aboutAction, &QAction::triggered,
this, &MainWindow::about);
connect(aboutQtAction, &QAction::triggered,
diff --git a/examples/widgets/mainwindows/dockwidgets/mainwindow.cpp b/examples/widgets/mainwindows/dockwidgets/mainwindow.cpp
index cd1189d8df..3493a66a67 100644
--- a/examples/widgets/mainwindows/dockwidgets/mainwindow.cpp
+++ b/examples/widgets/mainwindows/dockwidgets/mainwindow.cpp
@@ -215,7 +215,7 @@ void MainWindow::createActions()
fileMenu->addSeparator();
- QAction *quitAct = fileMenu->addAction(tr("&Quit"), this, &QWidget::close);
+ QAction *quitAct = fileMenu->addAction(tr("&Quit"), qApp, &QCoreApplication::quit);
quitAct->setShortcuts(QKeySequence::Quit);
quitAct->setStatusTip(tr("Quit the application"));
diff --git a/examples/widgets/mainwindows/mainwindow/mainwindow.cpp b/examples/widgets/mainwindows/mainwindow/mainwindow.cpp
index f2ea0d0697..7af5914e1f 100644
--- a/examples/widgets/mainwindows/mainwindow/mainwindow.cpp
+++ b/examples/widgets/mainwindows/mainwindow/mainwindow.cpp
@@ -93,7 +93,7 @@ void MainWindow::setupMenuBar()
menu->addAction(tr("Switch layout direction"),this, &MainWindow::switchLayoutDirection);
menu->addSeparator();
- menu->addAction(tr("&Quit"), this, &QWidget::close);
+ menu->addAction(tr("&Quit"), qApp, &QCoreApplication::quit);
mainWindowMenu = menuBar()->addMenu(tr("Main window"));
diff --git a/examples/widgets/richtext/textedit/textedit.cpp b/examples/widgets/richtext/textedit/textedit.cpp
index 5a4d62c646..fd2d4a8a16 100644
--- a/examples/widgets/richtext/textedit/textedit.cpp
+++ b/examples/widgets/richtext/textedit/textedit.cpp
@@ -171,7 +171,7 @@ void TextEdit::setupFileActions()
menu->addSeparator();
#endif
- a = menu->addAction(tr("&Quit"), this, &QWidget::close);
+ a = menu->addAction(tr("&Quit"), qApp, &QCoreApplication::quit);
a->setShortcut(Qt::CTRL | Qt::Key_Q);
}
diff --git a/examples/widgets/widgets/icons/mainwindow.cpp b/examples/widgets/widgets/icons/mainwindow.cpp
index 9c03401b6d..f893575f76 100644
--- a/examples/widgets/widgets/icons/mainwindow.cpp
+++ b/examples/widgets/widgets/icons/mainwindow.cpp
@@ -417,7 +417,7 @@ void MainWindow::createActions()
fileMenu->addSeparator();
- QAction *exitAct = fileMenu->addAction(tr("&Quit"), this, &QWidget::close);
+ QAction *exitAct = fileMenu->addAction(tr("&Quit"), qApp, &QCoreApplication::quit);
exitAct->setShortcuts(QKeySequence::Quit);
QMenu *viewMenu = menuBar()->addMenu(tr("&View"));