有谁知道事件处理程序如何管理发布的事件?
在我的应用程序中,我有两个线程(guiThread 和computationThread)。抛出异常后,我调用 postEvent(..)
到现有对话框。 Qt-Event-Handler 会阻止这个事件直到对话框关闭。
抱歉,我的问题有点模糊。如果我还有时间,我会写得更准确。我找到了解决办法。但对我来说,这个问题仍然很有趣。
最佳答案
正如 Qt 文档中提到的关于 QCoreApplication::postEvent :
When control returns to the main event loop, all events that are stored in the queue will be sent using the notify() function.
...这解释了为什么 Qt 事件处理程序会保留事件直到对话框关闭。
如果我正确理解你想做什么,我会尝试使用 sendEvent .
关于c++ - Qt 中的多线程事件处理程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52772/