prkhr4u
17th October 2013, 09:31
I am using 2 threads: GUI thread and 1 worker thread(grabthread),but i am not able to run them concurrently.
My main() function is like this :
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow win;
win.show();
GrabThread thread;
thread.start();
qDebug() << "hello from GUI thread " << a.thread()->currentThreadId();
thread.wait(); // do not exit before the thread is completed!
return a.exec();
}
and grabthread.h like this:
class GrabThread : public QThread
{
Q_OBJECT
private:
void run();
};
What is happening is that My GUI pops up only after grabthread has been fully executed and exits.
I want my GUI and grabthread to start simultaneously so that i can use multithreading.
My main() function is like this :
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
MainWindow win;
win.show();
GrabThread thread;
thread.start();
qDebug() << "hello from GUI thread " << a.thread()->currentThreadId();
thread.wait(); // do not exit before the thread is completed!
return a.exec();
}
and grabthread.h like this:
class GrabThread : public QThread
{
Q_OBJECT
private:
void run();
};
What is happening is that My GUI pops up only after grabthread has been fully executed and exits.
I want my GUI and grabthread to start simultaneously so that i can use multithreading.