同一信号的两个不同插槽

发布于 2024-12-18 10:33:06 字数 377 浏览 5 评论 0原文

当 m_serverClientControl 在其线程上发出 finishRunning() 时,我如何知道主线程中第一个/最后一个执行哪个插槽?在这种情况下,插槽如何排队?我对 Qt 如何将插槽事件放在线程事件队列上感到困惑。我已经阅读了该文档,但我仍然有点困惑。

connect( m_serverClientControl, SIGNAL( finishedRunning() ), m_serverClientControl, SLOT( deleteLater() ) );
connect( m_serverClientControl, SIGNAL( finishedRunning() ), this, SLOT( finishedRunningEmited() ) )

When m_serverClientControl emits finishedRunning() on its thread, How can I tell what slot gets executed first/last in the main thread? How do the slots get queued in a situation like this? I'm confused as how Qt places slot events on the thread event queue. I have read the document ion but I'm still a tad bit confused.

connect( m_serverClientControl, SIGNAL( finishedRunning() ), m_serverClientControl, SLOT( deleteLater() ) );
connect( m_serverClientControl, SIGNAL( finishedRunning() ), this, SLOT( finishedRunningEmited() ) )

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

初见终念 2024-12-25 10:33:06

来自 Qt 4.7 文档:

如果多个插槽连接到一个信号,这些插槽将被
按照它们连接的顺序一个接一个地执行,
当信号发出时。

http://doc.qt.io/archives/qt-4.7/signalsandslots .html#signals

因此,在您的情况下,应在 deleteLater() 之后调用 finishedRunningEmited()

From the Qt 4.7 docs:

If several slots are connected to one signal, the slots will be
executed one after the other, in the order they have been connected,
when the signal is emitted.

http://doc.qt.io/archives/qt-4.7/signalsandslots.html#signals

So in your case finishedRunningEmited() should be called after deleteLater().

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文