开发者

Emitting signals from other threads

I have a class which has a method that is called by the main thread and 3 other threads (2 QThreads and 1 made with QtConcurrent::run()). Inside this method I sometimes emit a signal. Is this okay or could it cause problems since I am not emittin开发者_C百科g signals that belong to the calling threads.


Yes, this is perfectly ok. QT does the inter-thread communication for you transparently. If the slot that needs to fire is in another thread then the signal gets queued and will be received by the destination thread when it enters its event loop.

You can try it and see what happens in a debugger.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜