Implementation of QThread in the Qt right made and what are its pitfalls?

Welcome!
Make a class implementation that must handle the data in background.
It turned out so:
Zagolovok:
class MyThread : public QObject
{
Q_OBJECT
public:
 explicit MyThread(QObject *parent);
~MyThread();

 void process();

signals:
 void finished();

public slots:
 void start();
 void stop();

private:
 QThread * _thread;
 bool _started;
};


Implementation:
#include "mythread.h"

MyThread::MyThread(QObject * parent)
 :QObject(0) //-- we should not be parents because we are in another thread
{
Q_ASSERT(parent!=0);
 qDebug()<<"MyThread created";

 _started = false;

 _thread = new QThread(0); //-- the thread itself should not have a parent that he hadn't demolished it inadvertently, while the thread is running

 connect(_thread, &QThread::started, this, &MyThread::process); //-- when you run a flow immediately begin work
 connect( this, &MyThread::finished, _thread, &QThread::quit ); //-- once all the work is done or stopped, to stop the flow
 connect(_thread, &QThread::finished, this, &QObject::deleteLater ); //-- once the stream is finished is removed
 connect(this, &QObject::destroyed, _thread, &QThread::deleteLater ); //-- once removed, remove the flow
 connect(parent, &QObject::destroyed, this, &MyThread::stop); //-- once the parent is removed, stop the flow

moveToThread(_thread);
}


void MyThread::process()
{
 while (true) {

 if (!_started) { break; }

 QApplication::processEvents(); //-- smoke bamboo
}

 emit finished();
}

void MyThread::start()
{
 qDebug()<<"MyThread start";

 _started = true;
_thread->start();
}

void MyThread::stop()
{
 qDebug()<<"MyThread stop";

 if (!_started) { //-- if we have not yet run, it is simply removed
this->deleteLater();
}

 _started = false;
}


MyThread::~MyThread()
{
 qDebug()<<"MyThread deleted";
}


Cause accordingly so:
_myThread = new MyThread(this);

In the Internet I have seen a bunch of articles: inheritance from QThread directly, "the Proper use of QThread" with Habra, etc.
Most of all did not like the fact that you need to write directly to the class an additional wrapper or a separate class or next to register new QThread(), moveToThread, then follow all the threads etc.

Tell me, is it normal implementation of the create, start, stop, and delete the stream and class, if not, why not? What can be the pitfalls?
July 4th 19 at 23:25
1 answer
July 4th 19 at 23:27
I do not see any implementation code does nothing, so the answer can't even smoke bamboo!
Implementation create, stop, remove the thread. - darrell commented on July 4th 19 at 23:30

Find more questions by tags Cross-platformmultithreadingQt