summaryrefslogtreecommitdiffstats
path: root/examples/corelib
diff options
context:
space:
mode:
Diffstat (limited to 'examples/corelib')
-rw-r--r--examples/corelib/corelib.pro3
-rw-r--r--examples/corelib/ipc/localfortuneclient/client.h4
-rw-r--r--examples/corelib/ipc/localfortuneserver/main.cpp3
-rw-r--r--examples/corelib/ipc/localfortuneserver/server.cpp8
-rw-r--r--examples/corelib/ipc/sharedmemory/dialog.cpp9
-rw-r--r--examples/corelib/ipc/sharedmemory/dialog.h6
-rw-r--r--examples/corelib/mimetypes/mimetypebrowser/main.cpp3
-rw-r--r--examples/corelib/mimetypes/mimetypebrowser/mainwindow.cpp4
-rw-r--r--examples/corelib/mimetypes/mimetypebrowser/mimetypemodel.cpp3
-rw-r--r--examples/corelib/serialization/cbordump/cbordump.pro3
-rw-r--r--examples/corelib/serialization/convert/cborconverter.cpp1
-rw-r--r--examples/corelib/serialization/convert/convert.pro3
-rw-r--r--examples/corelib/serialization/convert/xmlconverter.cpp6
-rw-r--r--examples/corelib/serialization/savegame/game.cpp2
-rw-r--r--examples/corelib/serialization/savegame/level.cpp2
-rw-r--r--examples/corelib/serialization/savegame/savegame.pro3
-rw-r--r--examples/corelib/threads/mandelbrot/mandelbrotwidget.cpp11
-rw-r--r--examples/corelib/threads/mandelbrot/mandelbrotwidget.h2
-rw-r--r--examples/corelib/threads/mandelbrot/renderthread.cpp2
-rw-r--r--examples/corelib/threads/mandelbrot/renderthread.h2
-rw-r--r--examples/corelib/threads/queuedcustomtype/block.cpp8
-rw-r--r--examples/corelib/threads/queuedcustomtype/block.h1
-rw-r--r--examples/corelib/threads/queuedcustomtype/renderthread.h2
-rw-r--r--examples/corelib/threads/queuedcustomtype/window.cpp31
-rw-r--r--examples/corelib/threads/queuedcustomtype/window.h2
-rw-r--r--examples/corelib/threads/semaphores/semaphores.cpp6
-rw-r--r--examples/corelib/threads/semaphores/semaphores.pro3
-rw-r--r--examples/corelib/threads/waitconditions/waitconditions.pro4
-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
39 files changed, 80 insertions, 106 deletions
diff --git a/examples/corelib/corelib.pro b/examples/corelib/corelib.pro
index 014e8af608..8caf2c16df 100644
--- a/examples/corelib/corelib.pro
+++ b/examples/corelib/corelib.pro
@@ -5,5 +5,6 @@ SUBDIRS = \
ipc \
mimetypes \
serialization \
- threads \
tools
+
+qtConfig(thread): SUBDIRS += threads
diff --git a/examples/corelib/ipc/localfortuneclient/client.h b/examples/corelib/ipc/localfortuneclient/client.h
index 0c1ede94c9..7248428440 100644
--- a/examples/corelib/ipc/localfortuneclient/client.h
+++ b/examples/corelib/ipc/localfortuneclient/client.h
@@ -53,14 +53,12 @@
#include <QDialog>
#include <QDataStream>
-
-#include <qlocalsocket.h>
+#include <QLocalSocket>
QT_BEGIN_NAMESPACE
class QLabel;
class QLineEdit;
class QPushButton;
-class QLocalSocket;
QT_END_NAMESPACE
class Client : public QDialog
diff --git a/examples/corelib/ipc/localfortuneserver/main.cpp b/examples/corelib/ipc/localfortuneserver/main.cpp
index 6f8ec539fe..430005a1d3 100644
--- a/examples/corelib/ipc/localfortuneserver/main.cpp
+++ b/examples/corelib/ipc/localfortuneserver/main.cpp
@@ -49,9 +49,6 @@
****************************************************************************/
#include <QApplication>
-#include <QtCore>
-
-#include <stdlib.h>
#include "server.h"
diff --git a/examples/corelib/ipc/localfortuneserver/server.cpp b/examples/corelib/ipc/localfortuneserver/server.cpp
index be8d4750d6..9be5ed5051 100644
--- a/examples/corelib/ipc/localfortuneserver/server.cpp
+++ b/examples/corelib/ipc/localfortuneserver/server.cpp
@@ -48,15 +48,11 @@
**
****************************************************************************/
+#include "server.h"
+
#include <QtWidgets>
#include <QtNetwork>
-#include <stdlib.h>
-
-#include "server.h"
-#include <qlocalserver.h>
-#include <qlocalsocket.h>
-
Server::Server(QWidget *parent)
: QDialog(parent)
{
diff --git a/examples/corelib/ipc/sharedmemory/dialog.cpp b/examples/corelib/ipc/sharedmemory/dialog.cpp
index ce5a4547bb..4e999d1bcf 100644
--- a/examples/corelib/ipc/sharedmemory/dialog.cpp
+++ b/examples/corelib/ipc/sharedmemory/dialog.cpp
@@ -51,7 +51,6 @@
#include "dialog.h"
#include <QFileDialog>
#include <QBuffer>
-#include <QtCore/QDebug>
/*!
\class Dialog
@@ -81,10 +80,10 @@ Dialog::Dialog(QWidget *parent)
: QDialog(parent), sharedMemory("QSharedMemoryExample")
{
ui.setupUi(this);
- connect(ui.loadFromFileButton, SIGNAL(clicked()), SLOT(loadFromFile()));
- connect(ui.loadFromSharedMemoryButton,
- SIGNAL(clicked()),
- SLOT(loadFromMemory()));
+ connect(ui.loadFromFileButton, &QPushButton::clicked,
+ this, &Dialog::loadFromFile);
+ connect(ui.loadFromSharedMemoryButton, &QPushButton::clicked,
+ this, &Dialog::loadFromMemory);
setWindowTitle(tr("SharedMemory Example"));
}
//! [0]
diff --git a/examples/corelib/ipc/sharedmemory/dialog.h b/examples/corelib/ipc/sharedmemory/dialog.h
index 1662654441..693333256c 100644
--- a/examples/corelib/ipc/sharedmemory/dialog.h
+++ b/examples/corelib/ipc/sharedmemory/dialog.h
@@ -51,8 +51,8 @@
#ifndef DIALOG_H
#define DIALOG_H
-#include <qdialog.h>
-#include <qsharedmemory.h>
+#include <QDialog>
+#include <QSharedMemory>
#include "ui_dialog.h"
//! [0]
@@ -61,7 +61,7 @@ class Dialog : public QDialog
Q_OBJECT
public:
- Dialog(QWidget *parent = 0);
+ Dialog(QWidget *parent = nullptr);
public slots:
void loadFromFile();
diff --git a/examples/corelib/mimetypes/mimetypebrowser/main.cpp b/examples/corelib/mimetypes/mimetypebrowser/main.cpp
index f4462df411..cf87004a01 100644
--- a/examples/corelib/mimetypes/mimetypebrowser/main.cpp
+++ b/examples/corelib/mimetypes/mimetypebrowser/main.cpp
@@ -55,9 +55,6 @@
#include <QCommandLineParser>
#include <QCommandLineOption>
-#include <QDebug>
-#include <QMimeDatabase>
-#include <QMimeType>
int main(int argc, char *argv[])
{
diff --git a/examples/corelib/mimetypes/mimetypebrowser/mainwindow.cpp b/examples/corelib/mimetypes/mimetypebrowser/mainwindow.cpp
index bc7ec17d1c..2e5c8069b8 100644
--- a/examples/corelib/mimetypes/mimetypebrowser/mainwindow.cpp
+++ b/examples/corelib/mimetypes/mimetypebrowser/mainwindow.cpp
@@ -185,7 +185,9 @@ void MainWindow::find()
m_findMatches.clear();
m_findIndex = 0;
- foreach (const QStandardItem *item, m_model->findItems(value, Qt::MatchContains | Qt::MatchFixedString | Qt::MatchRecursive))
+ const QList<QStandardItem *> items =
+ m_model->findItems(value, Qt::MatchContains | Qt::MatchFixedString | Qt::MatchRecursive);
+ for (const QStandardItem *item : items)
m_findMatches.append(m_model->indexFromItem(item));
statusBar()->showMessage(tr("%n mime types match \"%1\".", 0, m_findMatches.size()).arg(value));
updateFindActions();
diff --git a/examples/corelib/mimetypes/mimetypebrowser/mimetypemodel.cpp b/examples/corelib/mimetypes/mimetypebrowser/mimetypemodel.cpp
index ee83de092d..f755e060c6 100644
--- a/examples/corelib/mimetypes/mimetypebrowser/mimetypemodel.cpp
+++ b/examples/corelib/mimetypes/mimetypebrowser/mimetypemodel.cpp
@@ -50,9 +50,8 @@
#include "mimetypemodel.h"
-#include <QIcon>
-
#include <QDebug>
+#include <QIcon>
#include <QMimeDatabase>
#include <QTextStream>
#include <QVariant>
diff --git a/examples/corelib/serialization/cbordump/cbordump.pro b/examples/corelib/serialization/cbordump/cbordump.pro
index 7fb2ef69f0..8149cb1d4c 100644
--- a/examples/corelib/serialization/cbordump/cbordump.pro
+++ b/examples/corelib/serialization/cbordump/cbordump.pro
@@ -2,8 +2,7 @@ QT += core
QT -= gui
TARGET = cbordump
-CONFIG += console
-CONFIG -= app_bundle
+CONFIG += cmdline
TEMPLATE = app
diff --git a/examples/corelib/serialization/convert/cborconverter.cpp b/examples/corelib/serialization/convert/cborconverter.cpp
index f906c81062..ad69983eb1 100644
--- a/examples/corelib/serialization/convert/cborconverter.cpp
+++ b/examples/corelib/serialization/convert/cborconverter.cpp
@@ -56,7 +56,6 @@
#include <QCborArray>
#include <QCborValue>
#include <QDataStream>
-#include <QDebug>
#include <QFloat16>
#include <QFile>
#include <QMetaType>
diff --git a/examples/corelib/serialization/convert/convert.pro b/examples/corelib/serialization/convert/convert.pro
index d9b1de41e3..4c6b0b557a 100644
--- a/examples/corelib/serialization/convert/convert.pro
+++ b/examples/corelib/serialization/convert/convert.pro
@@ -2,8 +2,7 @@ QT += core
QT -= gui
TARGET = convert
-CONFIG += console
-CONFIG -= app_bundle
+CONFIG += cmdline
TEMPLATE = app
diff --git a/examples/corelib/serialization/convert/xmlconverter.cpp b/examples/corelib/serialization/convert/xmlconverter.cpp
index 62908273ce..e62801bf76 100644
--- a/examples/corelib/serialization/convert/xmlconverter.cpp
+++ b/examples/corelib/serialization/convert/xmlconverter.cpp
@@ -70,7 +70,7 @@ static QVariant variantFromXml(QXmlStreamReader &xml, Converter::Options options
static QVariantList listFromXml(QXmlStreamReader &xml, Converter::Options options)
{
QVariantList list;
- while (!xml.atEnd() && !xml.isEndElement()) {
+ while (!xml.atEnd() && !(xml.isEndElement() && xml.name() == QLatin1String("list"))) {
xml.readNext();
switch (xml.tokenType()) {
case QXmlStreamReader::StartElement:
@@ -107,7 +107,7 @@ static QVariantList listFromXml(QXmlStreamReader &xml, Converter::Options option
static VariantOrderedMap::value_type mapEntryFromXml(QXmlStreamReader &xml, Converter::Options options)
{
QVariant key, value;
- while (!xml.atEnd() && !xml.isEndElement()) {
+ while (!xml.atEnd() && !(xml.isEndElement() && xml.name() == QLatin1String("entry"))) {
xml.readNext();
switch (xml.tokenType()) {
case QXmlStreamReader::StartElement:
@@ -150,7 +150,7 @@ static QVariant mapFromXml(QXmlStreamReader &xml, Converter::Options options)
QVariantMap map1;
VariantOrderedMap map2;
- while (!xml.atEnd() && !xml.isEndElement()) {
+ while (!xml.atEnd() && !(xml.isEndElement() && xml.name() == QLatin1String("map"))) {
xml.readNext();
switch (xml.tokenType()) {
case QXmlStreamReader::StartElement:
diff --git a/examples/corelib/serialization/savegame/game.cpp b/examples/corelib/serialization/savegame/game.cpp
index 4caec71a03..c39362bc68 100644
--- a/examples/corelib/serialization/savegame/game.cpp
+++ b/examples/corelib/serialization/savegame/game.cpp
@@ -185,7 +185,7 @@ void Game::write(QJsonObject &json) const
json["player"] = playerObject;
QJsonArray levelArray;
- foreach (const Level level, mLevels) {
+ for (const Level &level : mLevels) {
QJsonObject levelObject;
level.write(levelObject);
levelArray.append(levelObject);
diff --git a/examples/corelib/serialization/savegame/level.cpp b/examples/corelib/serialization/savegame/level.cpp
index 8eda107f46..6fe46e8938 100644
--- a/examples/corelib/serialization/savegame/level.cpp
+++ b/examples/corelib/serialization/savegame/level.cpp
@@ -97,7 +97,7 @@ void Level::write(QJsonObject &json) const
{
json["name"] = mName;
QJsonArray npcArray;
- foreach (const Character npc, mNpcs) {
+ for (const Character &npc : mNpcs) {
QJsonObject npcObject;
npc.write(npcObject);
npcArray.append(npcObject);
diff --git a/examples/corelib/serialization/savegame/savegame.pro b/examples/corelib/serialization/savegame/savegame.pro
index 15a38c32ef..69e6b216f2 100644
--- a/examples/corelib/serialization/savegame/savegame.pro
+++ b/examples/corelib/serialization/savegame/savegame.pro
@@ -2,8 +2,7 @@ QT += core
QT -= gui
TARGET = savegame
-CONFIG += console
-CONFIG -= app_bundle
+CONFIG += cmdline
TEMPLATE = app
diff --git a/examples/corelib/threads/mandelbrot/mandelbrotwidget.cpp b/examples/corelib/threads/mandelbrot/mandelbrotwidget.cpp
index b3e4af5dc8..71d0abb09f 100644
--- a/examples/corelib/threads/mandelbrot/mandelbrotwidget.cpp
+++ b/examples/corelib/threads/mandelbrot/mandelbrotwidget.cpp
@@ -48,14 +48,13 @@
**
****************************************************************************/
+#include "mandelbrotwidget.h"
+
#include <QPainter>
#include <QKeyEvent>
#include <math.h>
-#include "mandelbrotwidget.h"
-
-
//! [0]
const double DefaultCenterX = -0.637011f;
const double DefaultCenterY = -0.0395159f;
@@ -75,7 +74,8 @@ MandelbrotWidget::MandelbrotWidget(QWidget *parent)
pixmapScale = DefaultScale;
curScale = DefaultScale;
- connect(&thread, SIGNAL(renderedImage(QImage,double)), this, SLOT(updatePixmap(QImage,double)));
+ connect(&thread, &RenderThread::renderedImage,
+ this, &MandelbrotWidget::updatePixmap);
setWindowTitle(tr("Mandelbrot"));
#ifndef QT_NO_CURSOR
@@ -117,7 +117,8 @@ void MandelbrotWidget::paintEvent(QPaintEvent * /* event */)
painter.save();
painter.translate(newX, newY);
painter.scale(scaleFactor, scaleFactor);
- QRectF exposed = painter.matrix().inverted().mapRect(rect()).adjusted(-1, -1, 1, 1);
+
+ QRectF exposed = painter.transform().inverted().mapRect(rect()).adjusted(-1, -1, 1, 1);
painter.drawPixmap(exposed, pixmap, exposed);
painter.restore();
}
diff --git a/examples/corelib/threads/mandelbrot/mandelbrotwidget.h b/examples/corelib/threads/mandelbrot/mandelbrotwidget.h
index a04bfa6e81..cb40962535 100644
--- a/examples/corelib/threads/mandelbrot/mandelbrotwidget.h
+++ b/examples/corelib/threads/mandelbrot/mandelbrotwidget.h
@@ -62,7 +62,7 @@ class MandelbrotWidget : public QWidget
Q_OBJECT
public:
- MandelbrotWidget(QWidget *parent = 0);
+ MandelbrotWidget(QWidget *parent = nullptr);
protected:
void paintEvent(QPaintEvent *event) override;
diff --git a/examples/corelib/threads/mandelbrot/renderthread.cpp b/examples/corelib/threads/mandelbrot/renderthread.cpp
index c57b696e25..eee44c7242 100644
--- a/examples/corelib/threads/mandelbrot/renderthread.cpp
+++ b/examples/corelib/threads/mandelbrot/renderthread.cpp
@@ -50,7 +50,7 @@
#include "renderthread.h"
-#include <QtWidgets>
+#include <QImage>
#include <cmath>
//! [0]
diff --git a/examples/corelib/threads/mandelbrot/renderthread.h b/examples/corelib/threads/mandelbrot/renderthread.h
index b5e9226fb8..4f0394d554 100644
--- a/examples/corelib/threads/mandelbrot/renderthread.h
+++ b/examples/corelib/threads/mandelbrot/renderthread.h
@@ -66,7 +66,7 @@ class RenderThread : public QThread
Q_OBJECT
public:
- RenderThread(QObject *parent = 0);
+ RenderThread(QObject *parent = nullptr);
~RenderThread();
void render(double centerX, double centerY, double scaleFactor, QSize resultSize);
diff --git a/examples/corelib/threads/queuedcustomtype/block.cpp b/examples/corelib/threads/queuedcustomtype/block.cpp
index a5058cc5ae..9cfad8673c 100644
--- a/examples/corelib/threads/queuedcustomtype/block.cpp
+++ b/examples/corelib/threads/queuedcustomtype/block.cpp
@@ -48,8 +48,6 @@
**
****************************************************************************/
-#include <QColor>
-#include <QRect>
#include "block.h"
Block::Block()
@@ -57,9 +55,8 @@ Block::Block()
}
Block::Block(const Block &other)
+ : m_rect(other.m_rect), m_color(other.m_color)
{
- m_rect = other.m_rect;
- m_color = other.m_color;
}
Block::~Block()
@@ -67,9 +64,8 @@ Block::~Block()
}
Block::Block(const QRect &rect, const QColor &color)
+ : m_rect(rect), m_color(color)
{
- m_rect = rect;
- m_color = color;
}
QColor Block::color() const
diff --git a/examples/corelib/threads/queuedcustomtype/block.h b/examples/corelib/threads/queuedcustomtype/block.h
index 547cc10f0a..eef48b25c2 100644
--- a/examples/corelib/threads/queuedcustomtype/block.h
+++ b/examples/corelib/threads/queuedcustomtype/block.h
@@ -52,7 +52,6 @@
#define BLOCK_H
#include <QColor>
-#include <QDebug>
#include <QMetaType>
#include <QRect>
diff --git a/examples/corelib/threads/queuedcustomtype/renderthread.h b/examples/corelib/threads/queuedcustomtype/renderthread.h
index 318ef293b4..9375b60e74 100644
--- a/examples/corelib/threads/queuedcustomtype/renderthread.h
+++ b/examples/corelib/threads/queuedcustomtype/renderthread.h
@@ -62,7 +62,7 @@ class RenderThread : public QThread
Q_OBJECT
public:
- RenderThread(QObject *parent = 0);
+ RenderThread(QObject *parent = nullptr);
~RenderThread();
void processImage(const QImage &image);
diff --git a/examples/corelib/threads/queuedcustomtype/window.cpp b/examples/corelib/threads/queuedcustomtype/window.cpp
index 2cefba1e17..183d9824cb 100644
--- a/examples/corelib/threads/queuedcustomtype/window.cpp
+++ b/examples/corelib/threads/queuedcustomtype/window.cpp
@@ -48,30 +48,34 @@
**
****************************************************************************/
-#include <QtWidgets>
#include "window.h"
+#include <QtWidgets>
//! [Window constructor start]
-Window::Window()
+Window::Window(QWidget *parent)
+ : QWidget(parent), thread(new RenderThread(this))
{
- thread = new RenderThread();
//! [Window constructor start] //! [set up widgets and connections]
- label = new QLabel();
+ label = new QLabel(this);
label->setAlignment(Qt::AlignCenter);
- loadButton = new QPushButton(tr("&Load image..."));
- resetButton = new QPushButton(tr("&Stop"));
+ loadButton = new QPushButton(tr("&Load image..."), this);
+ resetButton = new QPushButton(tr("&Stop"), this);
resetButton->setEnabled(false);
- connect(loadButton, SIGNAL(clicked()), this, SLOT(loadImage()));
- connect(resetButton, SIGNAL(clicked()), thread, SLOT(stopProcess()));
- connect(thread, SIGNAL(finished()), this, SLOT(resetUi()));
+ connect(loadButton, &QPushButton::clicked,
+ this, QOverload<>::of(&Window::loadImage));
+ connect(resetButton, &QPushButton::clicked,
+ thread, &RenderThread::stopProcess);
+ connect(thread, &RenderThread::finished,
+ this, &Window::resetUi);
//! [set up widgets and connections] //! [connecting signal with custom type]
- connect(thread, SIGNAL(sendBlock(Block)), this, SLOT(addBlock(Block)));
+ connect(thread, &RenderThread::sendBlock,
+ this, &Window::addBlock);
//! [connecting signal with custom type]
- QHBoxLayout *buttonLayout = new QHBoxLayout();
+ QHBoxLayout *buttonLayout = new QHBoxLayout;
buttonLayout->addStretch();
buttonLayout->addWidget(loadButton);
buttonLayout->addWidget(resetButton);
@@ -89,9 +93,10 @@ Window::Window()
void Window::loadImage()
{
QStringList formats;
- foreach (QByteArray format, QImageReader::supportedImageFormats())
+ const QList<QByteArray> supportedFormats = QImageReader::supportedImageFormats();
+ for (const QByteArray &format : supportedFormats)
if (format.toLower() == format)
- formats.append("*." + format);
+ formats.append(QLatin1String("*.") + QString::fromLatin1(format));
QString newPath = QFileDialog::getOpenFileName(this, tr("Open Image"),
path, tr("Image files (%1)").arg(formats.join(' ')));
diff --git a/examples/corelib/threads/queuedcustomtype/window.h b/examples/corelib/threads/queuedcustomtype/window.h
index c472c0fea7..4215dfd5a7 100644
--- a/examples/corelib/threads/queuedcustomtype/window.h
+++ b/examples/corelib/threads/queuedcustomtype/window.h
@@ -65,7 +65,7 @@ class Window : public QWidget
Q_OBJECT
public:
- Window();
+ Window(QWidget *parent = nullptr);
void loadImage(const QImage &image);
public slots:
diff --git a/examples/corelib/threads/semaphores/semaphores.cpp b/examples/corelib/threads/semaphores/semaphores.cpp
index 145624bb0b..a245b9906b 100644
--- a/examples/corelib/threads/semaphores/semaphores.cpp
+++ b/examples/corelib/threads/semaphores/semaphores.cpp
@@ -94,12 +94,6 @@ public:
}
fprintf(stderr, "\n");
}
-
-signals:
- void stringConsumed(const QString &text);
-
-protected:
- bool finish;
};
//! [4]
diff --git a/examples/corelib/threads/semaphores/semaphores.pro b/examples/corelib/threads/semaphores/semaphores.pro
index 69154e57eb..de909508c4 100644
--- a/examples/corelib/threads/semaphores/semaphores.pro
+++ b/examples/corelib/threads/semaphores/semaphores.pro
@@ -1,8 +1,7 @@
SOURCES += semaphores.cpp
QT = core
-CONFIG -= app_bundle
-CONFIG += console
+CONFIG += cmdline
# install
target.path = $$[QT_INSTALL_EXAMPLES]/corelib/threads/semaphores
diff --git a/examples/corelib/threads/waitconditions/waitconditions.pro b/examples/corelib/threads/waitconditions/waitconditions.pro
index 2dbe7df68a..19b56a246d 100644
--- a/examples/corelib/threads/waitconditions/waitconditions.pro
+++ b/examples/corelib/threads/waitconditions/waitconditions.pro
@@ -1,6 +1,6 @@
QT = core
-CONFIG -= moc app_bundle
-CONFIG += console
+CONFIG -= moc
+CONFIG += cmdline
SOURCES += waitconditions.cpp
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