Graham Labdon schreef op 24-3-2014 12:38: > 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 Yeah, you are doing some things wrong. Your moveToThread will fail, because GeneratorThread (confusing name for what seems to be a worker class?) has a parent. That causes that your worker is not in a different thread at all, but blocking your main thread instead.
André _______________________________________________ Interest mailing list Interest@qt-project.org http://lists.qt-project.org/mailman/listinfo/interest