Hi Vishal,
I don't currently have any working code I can show you, but I can explain what I did and it should be straightforward to implement the code yourself. The code you have that's freezing up the UI should be implemented in a separate worker thread. Subclass the QThread class for this. My QThread class doesn't do anything special. I just reimplemented the run() function as follows:
void MyThread::run()
{ exec(); }
void MyThread::run()
{ exec(); }
To copy to clipboard, switch view to plain text mode
You can then use QObject's moveToThread function to have that object's events processed in another thread (the one you created earlier).
MyThread* myBusyThread = new MyThread;
customQObject* myBusyObject = new customQObject;
myBusyObject->moveToThread(myBusyThread);
myBusyThread->start();
MyThread* myBusyThread = new MyThread;
customQObject* myBusyObject = new customQObject;
myBusyObject->moveToThread(myBusyThread);
myBusyThread->start();
To copy to clipboard, switch view to plain text mode
Invoke the methods that cause your GUI to normally freeze up (the heavy processing ones) using signals and slots and the processing for that object should be done in a separate thread, leaving the UI responsive.
Bookmarks