I am developing an application in Qt, I need to detect when you click outside the application to alternate hide () - show () with each click
Solved: through the event void changeEvent (QEvent * e); where we can capture the loss of focus of the current window, we know when we click outside of our application.
MainWindow.h
void changeEvent(QEvent * e);
MainWindow.cpp
void MainWindow::changeEvent(QEvent * e){
if(e->type() == QEvent::ActivationChange && this->isActiveWindow()){
qDebug("focus in");
} else {
qDebug("focus out");
}
}