summaryrefslogtreecommitdiffstats
path: root/examples/corelib/tools
diff options
context:
space:
mode:
Diffstat (limited to 'examples/corelib/tools')
-rw-r--r--examples/corelib/tools/contiguouscache/randomlistmodel.cpp1
-rw-r--r--examples/corelib/tools/contiguouscache/randomlistmodel.h2
-rw-r--r--examples/corelib/tools/customtype/main.cpp1
-rw-r--r--examples/corelib/tools/customtype/message.cpp8
-rw-r--r--examples/corelib/tools/customtype/message.h1
-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
-rw-r--r--examples/corelib/tools/doc/src/customtype.qdoc7
11 files changed, 22 insertions, 27 deletions
diff --git a/examples/corelib/tools/contiguouscache/randomlistmodel.cpp b/examples/corelib/tools/contiguouscache/randomlistmodel.cpp
index ccaa45a28b..d028b896f2 100644
--- a/examples/corelib/tools/contiguouscache/randomlistmodel.cpp
+++ b/examples/corelib/tools/contiguouscache/randomlistmodel.cpp
@@ -49,7 +49,6 @@
****************************************************************************/
#include "randomlistmodel.h"
#include <QRandomGenerator>
-#include <stdlib.h>
static const int bufferSize(500);
static const int lookAhead(100);
diff --git a/examples/corelib/tools/contiguouscache/randomlistmodel.h b/examples/corelib/tools/contiguouscache/randomlistmodel.h
index e6192b434f..1fabb0d9f5 100644
--- a/examples/corelib/tools/contiguouscache/randomlistmodel.h
+++ b/examples/corelib/tools/contiguouscache/randomlistmodel.h
@@ -59,7 +59,7 @@ class RandomListModel : public QAbstractListModel
{
Q_OBJECT
public:
- RandomListModel(QObject *parent = 0);
+ RandomListModel(QObject *parent = nullptr);
~RandomListModel();
int rowCount(const QModelIndex & = QModelIndex()) const override;
diff --git a/examples/corelib/tools/customtype/main.cpp b/examples/corelib/tools/customtype/main.cpp
index ced317e208..d50bf9efea 100644
--- a/examples/corelib/tools/customtype/main.cpp
+++ b/examples/corelib/tools/customtype/main.cpp
@@ -49,6 +49,7 @@
****************************************************************************/
#include <QCoreApplication>
+#include <QDebug>
#include <QVariant>
#include "message.h"
diff --git a/examples/corelib/tools/customtype/message.cpp b/examples/corelib/tools/customtype/message.cpp
index 8b2c295e46..cc96aee978 100644
--- a/examples/corelib/tools/customtype/message.cpp
+++ b/examples/corelib/tools/customtype/message.cpp
@@ -50,15 +50,16 @@
#include "message.h"
+#include <QDebug>
+
//! [Message class implementation]
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()
@@ -67,9 +68,8 @@ Message::~Message()
//! [Message class implementation]
Message::Message(const QString &body, const QStringList &headers)
+ : m_body(body), m_headers(headers)
{
- m_body = body;
- m_headers = headers;
}
//! [custom type streaming operator]
diff --git a/examples/corelib/tools/customtype/message.h b/examples/corelib/tools/customtype/message.h
index 9871a7d52d..c1b8243237 100644
--- a/examples/corelib/tools/customtype/message.h
+++ b/examples/corelib/tools/customtype/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/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);
diff --git a/examples/corelib/tools/doc/src/customtype.qdoc b/examples/corelib/tools/doc/src/customtype.qdoc
index 91b814808a..7ccfc95c70 100644
--- a/examples/corelib/tools/doc/src/customtype.qdoc
+++ b/examples/corelib/tools/doc/src/customtype.qdoc
@@ -117,8 +117,8 @@
\snippet tools/customtype/main.cpp storing a custom value
- Alternatively, the QVariant::fromValue() and qVariantSetValue() functions
- can be used if you are using a compiler without support for member template
+ Alternatively, the QVariant::fromValue() function can be used if
+ you are using a compiler without support for member template
functions.
The value can be retrieved using the QVariant::value() member template
@@ -126,9 +126,6 @@
\snippet tools/customtype/main.cpp retrieving a custom value
- Alternatively, the qVariantValue() template function can be used if
- you are using a compiler without support for member template functions.
-
\section1 Further Reading
The custom \c Message type can also be used with direct signal-slot