Qt 4.5 - 发出信号是函数调用还是线程,它会阻塞吗?

标签 qt qt4

我不确定 Qt 4.5 中信号/插槽机制的性质。发出信号时,是阻塞函数调用还是线程?说这个

emit GrabLatestData();

// proceed with latest data

在继续下一行之前,所有的信号/槽链都会被解析吗?

最佳答案

这取决于。来自 documentation :

When a signal is emitted, the slots connected to it are usually executed immediately, just like a normal function call. When this happens, the signals and slots mechanism is totally independent of any GUI event loop. Execution of the code following the emit statement will occur once all slots have returned. The situation is slightly different when using queued connections; in such a case, the code following the emit keyword will continue immediately, and the slots will be executed later.



所以在正常情况下,它将是同步和阻塞的,而对于排队连接,它将是异步和非阻塞的。

关于Qt 4.5 - 发出信号是函数调用还是线程,它会阻塞吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1264887/

相关文章:

c++ - 总是在删除之前释放一个 QSemaphore?

qt - 创建可以与串行端口通信的 Mac/Windows 应用程序

静态链接后资源中的qt png损坏

c++ - 调试 Qt 信号、插槽和连接

qt4 - 如何聚焦新标签?

c++ - 如何从另一个线程中引发的 Boost 信号更新 Qt GUI?

c++ - 无法打开包含文件 : 'atlbase.h' : No such file or directory

sql - QSqlDatabase 和 QTableView 不同步(SQLite)

c++ - 使用 LibAV 解码 UDP 流 : Insufficient Buffer Size

c++ - 是否可以在 Qt 中使用带下划线的字母作为键盘快捷键?