[Qt-interest] Is it safe to connect different threads by Qt::DirectConnection?
donglongchao
donglongchao at 163.com
Sat Dec 5 05:45:50 CET 2009
Hi,
I have a question when I develop my muti-thread programme.Now I have one GUI thread and one work thread and there is a QTimer object lives in my work thread.And I want to connect the timeout() signal of the QTimer object to a slot of my work thread.Also I want the slot function to run in the work thread not the GUI thread.Since the QTimer object and the work thread live in different threads,if I do not set the fifth parameter of QObject::connect(...),the slot function will run in GUI thread.If I set the fifth parameter to be Qt::DirectConnection,then the slot will run in the thread where the QTimer object lives.This is what I want.So I want to know if it is safe to do like this?Or is it the right way to achieve my requirement?If not,what is the right way?Could anyone help?Any suggestion will be appreciated.
Thanks in advance.
Longchao.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20091205/2d66aa96/attachment.html
More information about the Qt-interest-old
mailing list