Main event loop freezing during time consuming function
-
As I'm working on an application that has quite some functions which are time consuming,
I quickly found the "article":http://doc.qt.digia.com/qq/qq27-responsive-guis.htmlAs the QCoreApplication::processEvents() approach wasn't feasible, I went for
the option with Qthreads and the local QEventLoop.@
q = new QEventLoop;
thread = new QThread;
kinectObject->runOrientation = 1;
connect(thread, SIGNAL(started()), kinectObject, SLOT(run()));
connect(kinectObject, SIGNAL(runFinished()), thread, SLOT(quit()));
connect(kinectObject, SIGNAL(runFinished()), thread, SLOT(deleteLater()));
connect(kinectObject, SIGNAL(runFinished()), q, SLOT(quit()));
connect(kinectObject, SIGNAL(runFinished()), q, SLOT(deleteLater()));
thread->start();
q->exec();
@Now if my kinectObject slot run() only has a Sleep(5000) in it, the GUI stays
responsive, but if I place the code that through a boost thread or interface to
the OpenNI drivers, the GUI becomes irresponsive.So my question is to how improve my code such that my GUI stays responsive
and probably also without using the local QEventLoop? As I understood the local
eventloop also catches other events like network that should go somewhere else.