[Interest] QThread

Graham Labdon Graham.Labdon at avalonsciences.com
Mon Mar 24 12:38:54 CET 2014


Hi
I am experimenting with QThreads
The basic idea is to have a thread performing some task and to have a button on the UI that can stop this operation 

So I have a class that will perform the operation called GeneratorThread that has a start slot
In the main ui class I create an instance of the class -

m_generatorThread = new GeneratorThread(this);

Then I call moveToThread  and make the connections-
m_generatorThread->moveToThread(m_thread)
connect(m_thread,&QThread::started,m_generatorThread,& GeneratorThread::start);
connect(m_generatorThread,&GeneratorThread::finished,m_thread,&QThread::quit);
connect(m_generatorThread,&GeneratorThread::finished,m_generatorThread,&GeneratorThread::deleteLater);
connect(m_thread,&QThread::finished,m_generatorThread,&GeneratorThread::deleteLater);

And finally I start the thread
m_thread->start()

The generatorThread simply writes a debug message every second and I see this happening.
The problem is that my ui does not respond to any input - so my stop button will not work

I am obviously doing something wrong and would appreciate any help

Thanks





More information about the Interest mailing list