QThread插槽行为 [英] QThread Slots behavior

查看:182
本文介绍了QThread插槽行为的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新的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?

推荐答案


我是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插槽行为的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆