[Qt-interest] QThread event loop running in main thread?
lbutler3 at comcast.net
lbutler3 at comcast.net
Mon Dec 27 05:05:02 CET 2010
I seem to be having trouble with a QThread and signals/slots. I noticed this when the Ui for my application stopped responding when a thread got busy. I've boiled it down to the fact that the thread event loop seems to be running in the main thread.
In my main window constructor I do:
connect(this, SIGNAL(tweakThread()), &myThread, SLOT(tweak()), Qt::QueuedConnection);
myThread.start();
The run method for the thread basically just calls:
this->exec();
When the main window does:
emit tweakThread();
the tweak() method on myThread runs immediately in the main thread of execution, not in the thread of execution of myThread.
In my full application I'd like to do some extended calculations in the thread tweak() routine without hanging the user interface.
Is this the expected behavior? Is there a way to get the thread's event loop to run in the thread?
Lee
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20101227/bfdfe49d/attachment.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: MainWindow.h
Type: text/x-chdr
Size: 984 bytes
Desc: not available
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20101227/bfdfe49d/attachment.bin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: MyThread.h
Type: text/x-chdr
Size: 1034 bytes
Desc: not available
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20101227/bfdfe49d/attachment-0001.bin
More information about the Qt-interest-old
mailing list