How to detect if a window has been minimized/Alt-Tab'd ??
Hi,
The title says it all. I want to do something evverytime my window is minimized, or put to background, everytime I switch to other window.
I thought it had to do with losing focus so I tried :
Code:
{
if( event
->type
() == QEvent::FocusOut ) {
Note::writeToFile();
return true;
}
return false;
}
with
Code:
installEventFilter(this);
on the cosntructor.
But it didn't work. It works with QEvent::KeyPress however.
Re: How to detect if a window has been minimized/Alt-Tab'd ??
In Qt5 there is a windowStateChanged signal in QWindow class and applicationStateChanged signal in QGuiApplication. I don't remember if there are equivalent signals in Qt4.
Re: How to detect if a window has been minimized/Alt-Tab'd ??
The eventFilter() is really designed for monitoring and dealing with the events of another QObject (as in the docs example). There are dedicated (protected) handlers for the focus out, hide and show events of this object that should be useful.
Re: How to detect if a window has been minimized/Alt-Tab'd ??
The windowStateChanged worked for minimizing, but not when I just switch to another window, if it's put to background. Any ideas?
Re: How to detect if a window has been minimized/Alt-Tab'd ??
Try with this->isActiveWindow() to know whether your current window is active or not.