Answer the question
In order to leave comments, you need to log in
QThread why is the class destructor not called?
Greetings!
Created a new FindTargets class inherited from QObject
with a stream running in the AppCore class in the constructor:
ft = new FindTargets(0);
thread = new QThread(0);
connect(thread, SIGNAL(started()), ft, SLOT(process()));
connect(ft, SIGNAL(finished()), thread, SLOT(quit()));
connect(ft, SIGNAL(finished()), ft, SLOT(deleteLater()));
connect(thread, SIGNAL(finished()), thread, SLOT(deleteLater()));
ft->moveToThread(thread);
thread->start();
AppCore::~AppCore()
{
qDebug()<<"AppCore::~AppCore";
ft->stop();
}
Answer the question
In order to leave comments, you need to log in
In general, I found a solution.
The problem was that the thread and the working class were created in a class that itself is killed when the last program window is closed, and since everything was connected via signal slots, they stopped being called. It was only necessary to leave the main class alive after closing the window, then everything returned to normal, well, I just added that the main class would be killed when the thread finished working.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question