How to detect that my application lost focus in Qt?

陌路散爱 提交于 2019-12-04 06:19:32

The event you are looking for is QEvent::ApplicationDeactivate: "The application has been suspended, and is unavailable to the user".

You can install an event filter on your QApplication instance to catch this event. See the documentation for QObject::installEventFilter(QObject*) for more details how this works.

Since Qt 5.2 the QEvent::ApplicationDeactivate event is deprecated. The correct way to identify when an application is deactivated in Qt 5.2 (or later) is to use the QGuiApplication::applicationStateChanged(Qt::ApplicationState state) signal.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!