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

查看:29
本文介绍了如何拦截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天全站免登陆