Hello,

You can install eventFilter for qApp in for instance your QMainWindow, 
and after that do something like

bool MainWindow::eventFilter(QObject * watched, QEvent * event)
{
     if(watched == qApp) {
             if(event->type() == QEvent::ApplicationActivate)
                 myAppIsActivated = true;
             else if(event->type() == QEvent::ApplicationDeactivate)
                 myAppIsActivated = false;
     }
     return QMainWindow::eventFilter(watched, event);
}

and then deal with myAppIsActivated to show or not your QWidgets.

That's what we do (a bit more complicated because we need to act when 
the application goes fore/background so I don't even know if the code 
above compiles but that's the idea).

Maybe (probably) there is something better if you just want to know if 
it's activated or not...

Philippe Lelong

Le 02-03-2015 20:14, John Weeks a écrit :
> Macintosh, Qt 5.4
> 
> I have a complaint from a customer who is alpha testing our
> application port to Qt. He uses the Application Menu Hide Others item
> to hide our application while he does other work in other
> applications. Since our application is scriptable and can do
> computations that literally take hours or days, he wants to set the
> application running his script while does other work in other
> applications. To avoid the flashing windows while his script runs, he
> uses the Hide Others to hide our application.
> 
> But QWidget::show() causes the application to un-hide. So two 
> questions:
> 
> 1) Is there a way to tell Qt that it should honor the application being 
> hidden?
> 
> 2) Is there a way to ask Qt if the application is hidden? If I could
> find that out, I could manage the visibility of our windows myself.
> 
> Thanks,
> 
> -John Weeks
> 
> _______________________________________________
> Interest mailing list
> Interest@qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest

_______________________________________________
Interest mailing list
Interest@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest

Reply via email to