summaryrefslogtreecommitdiffstats
path: root/examples/network/blockingfortuneclient/blockingclient.cpp
diff options
context:
space:
mode:
authorChristian Ehrlicher <ch.ehrlicher@gmx.de>2019-11-01 13:21:32 +0100
committerChristian Ehrlicher <ch.ehrlicher@gmx.de>2019-11-06 10:57:23 +0100
commite85de7d787498624020884ef2e269c15faf76b50 (patch)
tree30044fb755fdf0c3015b21a14a1fa871526632a9 /examples/network/blockingfortuneclient/blockingclient.cpp
parent66b6e28c0158b8c4e96ddf08908a538d865ce63a (diff)
Cleanup network examples
Cleanup network examples: - use nullptr - use member-init - adjust includes - use new-style connects Change-Id: I80aa230168e5aec88a1bc93bbf49a471bfc30e7b Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Diffstat (limited to 'examples/network/blockingfortuneclient/blockingclient.cpp')
-rw-r--r--examples/network/blockingfortuneclient/blockingclient.cpp39
1 files changed, 20 insertions, 19 deletions
diff --git a/examples/network/blockingfortuneclient/blockingclient.cpp b/examples/network/blockingfortuneclient/blockingclient.cpp
index 607215cf13..5a1500d084 100644
--- a/examples/network/blockingfortuneclient/blockingclient.cpp
+++ b/examples/network/blockingfortuneclient/blockingclient.cpp
@@ -96,20 +96,21 @@ BlockingClient::BlockingClient(QWidget *parent)
buttonBox->addButton(getFortuneButton, QDialogButtonBox::ActionRole);
buttonBox->addButton(quitButton, QDialogButtonBox::RejectRole);
- connect(getFortuneButton, SIGNAL(clicked()), this, SLOT(requestNewFortune()));
- connect(quitButton, SIGNAL(clicked()), this, SLOT(close()));
-
- connect(hostLineEdit, SIGNAL(textChanged(QString)),
- this, SLOT(enableGetFortuneButton()));
- connect(portLineEdit, SIGNAL(textChanged(QString)),
- this, SLOT(enableGetFortuneButton()));
+ connect(getFortuneButton, &QPushButton::clicked,
+ this, &BlockingClient::requestNewFortune);
+ connect(quitButton, &QPushButton::clicked,
+ this, &BlockingClient::close);
+
+ connect(hostLineEdit, &QLineEdit::textChanged,
+ this, &BlockingClient::enableGetFortuneButton);
+ connect(portLineEdit, &QLineEdit::textChanged,
+ this, &BlockingClient::enableGetFortuneButton);
+//! [0]
+ connect(&thread, &FortuneThread::newFortune,
+ this, &BlockingClient::showFortune);
+ connect(&thread, &FortuneThread::error,
+ this, &BlockingClient::displayError);
//! [0]
- connect(&thread, SIGNAL(newFortune(QString)),
- this, SLOT(showFortune(QString)));
-//! [0] //! [1]
- connect(&thread, SIGNAL(error(int,QString)),
- this, SLOT(displayError(int,QString)));
-//! [1]
QGridLayout *mainLayout = new QGridLayout;
mainLayout->addWidget(hostLabel, 0, 0);
@@ -124,30 +125,30 @@ BlockingClient::BlockingClient(QWidget *parent)
portLineEdit->setFocus();
}
-//! [2]
+//! [1]
void BlockingClient::requestNewFortune()
{
getFortuneButton->setEnabled(false);
thread.requestNewFortune(hostLineEdit->text(),
portLineEdit->text().toInt());
}
-//! [2]
+//! [1]
-//! [3]
+//! [2]
void BlockingClient::showFortune(const QString &nextFortune)
{
if (nextFortune == currentFortune) {
requestNewFortune();
return;
}
-//! [3]
+//! [2]
-//! [4]
+//! [3]
currentFortune = nextFortune;
statusLabel->setText(currentFortune);
getFortuneButton->setEnabled(true);
}
-//! [4]
+//! [3]
void BlockingClient::displayError(int socketError, const QString &message)
{