diff options
Diffstat (limited to 'examples/corelib/threads/queuedcustomtype')
5 files changed, 19 insertions, 20 deletions
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 0d3f80aba4..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); 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: |