summaryrefslogtreecommitdiffstats
path: root/examples/corelib/tools/customtypesending
diff options
context:
space:
mode:
Diffstat (limited to 'examples/corelib/tools/customtypesending')
-rw-r--r--examples/corelib/tools/customtypesending/main.cpp11
-rw-r--r--examples/corelib/tools/customtypesending/message.cpp6
-rw-r--r--examples/corelib/tools/customtypesending/message.h1
-rw-r--r--examples/corelib/tools/customtypesending/window.cpp9
-rw-r--r--examples/corelib/tools/customtypesending/window.h2
5 files changed, 14 insertions, 15 deletions
diff --git a/examples/corelib/tools/customtypesending/main.cpp b/examples/corelib/tools/customtypesending/main.cpp
index 966c284d9a..c5d643b9d1 100644
--- a/examples/corelib/tools/customtypesending/main.cpp
+++ b/examples/corelib/tools/customtypesending/main.cpp
@@ -57,19 +57,20 @@ int main(int argc, char *argv[])
{
QApplication app(argc, argv);
- Window window1;
QStringList headers;
headers << "Subject: Hello World"
<< "From: address@example.com";
QString body = "This is a test.\r\n";
Message message(body, headers);
+
+ Window window1;
window1.setMessage(message);
Window window2;
- QObject::connect(&window1, SIGNAL(messageSent(Message)),
- &window2, SLOT(setMessage(Message)));
- QObject::connect(&window2, SIGNAL(messageSent(Message)),
- &window1, SLOT(setMessage(Message)));
+ QObject::connect(&window1, &Window::messageSent,
+ &window2, &Window::setMessage);
+ QObject::connect(&window2, &Window::messageSent,
+ &window1, &Window::setMessage);
window1.show();
window2.show();
return app.exec();
diff --git a/examples/corelib/tools/customtypesending/message.cpp b/examples/corelib/tools/customtypesending/message.cpp
index c990768079..9386b93898 100644
--- a/examples/corelib/tools/customtypesending/message.cpp
+++ b/examples/corelib/tools/customtypesending/message.cpp
@@ -55,9 +55,8 @@ Message::Message()
}
Message::Message(const Message &other)
+ : m_body(other.m_body), m_headers(other.m_headers)
{
- m_body = other.m_body;
- m_headers = other.m_headers;
}
Message::~Message()
@@ -65,9 +64,8 @@ Message::~Message()
}
Message::Message(const QString &body, const QStringList &headers)
+ : m_body(body), m_headers(headers)
{
- m_body = body;
- m_headers = headers;
}
QString Message::body() const
diff --git a/examples/corelib/tools/customtypesending/message.h b/examples/corelib/tools/customtypesending/message.h
index a8d6d6be05..a93f111e45 100644
--- a/examples/corelib/tools/customtypesending/message.h
+++ b/examples/corelib/tools/customtypesending/message.h
@@ -51,7 +51,6 @@
#ifndef MESSAGE_H
#define MESSAGE_H
-#include <QDebug>
#include <QMetaType>
#include <QStringList>
diff --git a/examples/corelib/tools/customtypesending/window.cpp b/examples/corelib/tools/customtypesending/window.cpp
index 224656f94c..db4b52a985 100644
--- a/examples/corelib/tools/customtypesending/window.cpp
+++ b/examples/corelib/tools/customtypesending/window.cpp
@@ -52,14 +52,15 @@
#include "window.h"
//! [Window constructor]
-Window::Window()
+Window::Window(QWidget *parent)
+ : QWidget(parent), editor(new QTextEdit(this))
{
- editor = new QTextEdit();
QPushButton *sendButton = new QPushButton(tr("&Send message"));
- connect(sendButton, SIGNAL(clicked()), this, SLOT(sendMessage()));
+ connect(sendButton, &QPushButton::clicked,
+ this, &Window::sendMessage);
- QHBoxLayout *buttonLayout = new QHBoxLayout();
+ QHBoxLayout *buttonLayout = new QHBoxLayout;
buttonLayout->addStretch();
buttonLayout->addWidget(sendButton);
buttonLayout->addStretch();
diff --git a/examples/corelib/tools/customtypesending/window.h b/examples/corelib/tools/customtypesending/window.h
index d050931b74..048fecef67 100644
--- a/examples/corelib/tools/customtypesending/window.h
+++ b/examples/corelib/tools/customtypesending/window.h
@@ -62,7 +62,7 @@ class Window : public QWidget
Q_OBJECT
public:
- Window();
+ Window(QWidget *parent = nullptr);
signals:
void messageSent(const Message &message);