跟随发出的信号到其连接的插槽? [英] Follow an emitted signal to its connected slot(s)?

查看:82
本文介绍了跟随发出的信号到其连接的插槽?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我了解到Qt信号已放入事件队列中,然后稍后在事件循环看到它时调用连接的插槽。因此,在调试时介入是没有意义的。但是我真的很想看到,在一个足够大的应用程序中,我无法一次记住所有这些内容,而控制流最终结束了。



所以有没有一种方法可以找到连接到信号的插槽,或者可能基于 connect(...); 调用,或者实际上是在调试时?






在Qt Creator 3.5.1中(基于Qt 5.5.1(GCC 5.2.1 20151129,64位) ):


  1. Ctrl + Shift + U (查找用法)仅返回 emit signal(); 在源中, void signal(); 在标头中。


    • 如果它还返回 connect(...,SIGNAL(signal()),.. 。,SLOT(slot())); ,这样我就可以在 slot()上 F2 (转到定义) 并在其中放入断点


  2. 纯文本搜索将返回一堆与其他类同名的不相关信号,因此也没有帮助。


解决方案

您可以使用


I understand that a Qt signal is put onto the event queue, and then the connected slots are called later when the event loop sees it. So it doesn't make sense to "step into" it when debugging. But I really do want to see, in a large enough app that I can't keep all of it in mind at once, where the control flow ends up.

So is there a way to find the slot(s) that are connected to a signal, either potentially based on connect(...); calls or actually at the moment when debugging?


In Qt Creator 3.5.1 (Based on Qt 5.5.1 (GCC 5.2.1 20151129, 64 bit)):

  1. Ctrl+Shift+U (find usages) only returns emit signal(); in the source and void signal(); in the header.
    • It'd be really nice if it would also return connect(..., SIGNAL(signal()), ..., SLOT(slot())); so I could then F2 (go to definition) on slot() and put a breakpoint in it.
  2. A plaintext search returns a bunch of unrelated signals with the same name in other classes, so that's not really helpful either.

解决方案

You can use New Signal Slot Syntax :

connect(sender, &Sender::valueChanged,receiver, &Receiver::updateValue);

With this connection you can find usage and Qt will find connection line.

这篇关于跟随发出的信号到其连接的插槽?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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