是否可以连接到 QApplication 通知信号?

Is it possible to connect to QApplication notify signal?

我在这里看到了 QApplication::notify 用法的示例:How to detect if a Qt GUI application has been idle, inside the app itself (Qt)?

我需要在不基于 QApplication 方法的情况下做同样的事情。 qAppconnectNotify 方法,所以我想应该可以对 notify 信号采取自己的行动。

如果可能的话,我需要一个基本的例子,我该如何连接到这个事件。

也许您应该看一下事件过滤器,您可以为所有 QObject 安装它:QObject::installEventFilter

编写您自己的 class,您从 QObject 继承并实现 eventFilter 方法,在其中插入您的事件处理逻辑。 然后将此 class 的对象安装到您的 QApplication 实例(例如 qApp