如何截获Qt中给定事件发出的所有信号? [英] How to intercept ALL signals emitted by a given event in Qt?

查看:186
本文介绍了如何截获Qt中给定事件发出的所有信号?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以想象,根据事件的不同,可能会有很多,但同时,我想这可能是调试的最佳方法,也是一个有趣的课程。

I can imagine that there might be quite a few of them depending on the event, but at the same time, I guess this can be a best way to debug, and an interesting lesson.

我为什么需要它?我正在使用基于 QWidget 的自定义类,当我取消附加基于 QDockWidget 的类时,该类不会扩展在同一窗口中。知道在断开此扩展坞小部件断开连接时会发出什么信号,这将帮助我选择需要在自定义类中覆盖的方法。

Why would I need it? I'm using some custom class based on the QWidget, which does not expand when I de-attach a QDockWidget based in the same window. Knowing what signals are emitted when this dock widget is being de-attached would help me to chose which method I need to overwrite in my custom class.

不想检查文档中所有可能的信号,而只是查看我在应用程序中执行某些操作时发出的信号。

In other words, I don't want to check every possible signal from the documentation, but just see which signals are emitted when I perform some action in my application.

推荐答案

使用任何公共API都不可能。

This isn't possible with any public API.

但是,如果将代码放入基于QTestLib的单元测试中,则可以运行单元测试使用 -vs 打印每个发出的信号。

But, if you put your code into a QTestLib-based unit test, you can run the unit test with -vs to print out every emitted signal.

这篇关于如何截获Qt中给定事件发出的所有信号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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