问题描述
我是新的C ++和Qt,我想知道如果我在 object1
中发出信号
在 thread1
,另一个 object2
运行在另一个 thread2
object2
运行无限循环进行处理?将 thread2
永远不会调用 object2
中的正忙着运行循环?
I am new to C++ and Qt and I am wondering what happens if I emit a signal
in object1
running in thread1
, to another object2
running in another thread2
and object2
is running an infinite loop for processing? Will the slot
in object2
never be called since the thread2
is busy running the loop?
推荐答案
是和否。
如果你不处理事件,那么线程将不会像你所期望的那样处理事件,信号和槽。
If you do not process events, then the thread will not chance to process the events, signals, and slots as you would expect.
但是,你可以在那里做一个事件循环,偶尔会处理进来的事件,然后它会按照你期望的方式工作。
However, you could make an event loop there that occasionally does process the events coming in, and then it would work as you expect it to.
我的更长的解释可以查看想要获取有关该主题的更多详细信息的人员。
My longer explanation than this is available here for people who would like to get more detailed information about the topic.
这篇关于QThread插槽行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!