gpt4 book ai didi

c++ - Qt 中的多线程事件处理程序

转载 作者:行者123 更新时间:2023-11-30 03:12:51 27 4
gpt4 key购买 nike

有谁知道事件处理程序如何管理发布的事件?

在我的应用程序中,我有两个线程(guiThreadcomputationThread)。抛出异常后,我调用 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/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com