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

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

 void process();

 void finished();

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

 QThread * _thread;
 bool _started;

#include "mythread.h"

MyThread::MyThread(QObject * parent)
 :QObject(0) //-- we should not be parents because we are in another thread
 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


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

 if (!_started) { break; }

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

 emit finished();

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

 _started = true;

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

 if (!_started) { //-- if we have not yet run, it is simply removed

 _started = false;

 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