M
M
Maxim Rudnev2017-07-24 17:23:37
Qt
Maxim Rudnev, 2017-07-24 17:23:37

How to run a class method inside the constructor of the same class in a parallel thread?

So is it possible at all?

M_RESULT *rs=new M_RESULT(s); // хотелось в этом классе сделать бесконечный цикл с опросом устройств
 thread=new QThread(); //нужно ли тут передавать this?
 rs->moveToThread(thread);
 thread->start();
 connect(rs, &M_RESULT::valueChaged, this, &MyTreeModel::sensor_valueChanged);
 connect(this, &MyTreeModel::destroyed, thread, &QThread::terminate);

as a result, there is a cycle, and the window with the application is not visible, the constructor does not complete its work.
There is a feeling that I am doing something fundamentally wrong.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Armenian Radio, 2017-07-24
@gbg

Read

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question