How to determine if my app is active...
Hello,
I would like to be able to determine if my Qt application is the 'current' application. E.g. on Windows XP and MacOS, there is one application that is considered to be the 'current' one. I thought that detecting events with type equal to QEvent::ApplicationActivated or QEvent::ApplicationDeactivated would be the correct way to detect this change. I overrode QApplication::event(QEvent *e) and put in cases for the two types mentioned above, but these two events do not seem to be received (at least on Windows XP). Does anyone know how to detect that the application has become active or inactive?
Thanks,
Ben
Re: How to determine if my app is active...
QApplication::activeWindow() and QApplication::focusWidget(). If they both return 0, none of the applications windows is active, hence the application does not have focus (in your terms -- is not the "current" one).
Re: How to determine if my app is active...
Use for main app win next events
Quote:
QEvent::WindowActivate - Window was activated.
QEvent::WindowDeactivate - Window was deactivated.
Re: How to determine if my app is active...
Quote:
Originally Posted by zlatko
Use for main app win next events
Why for main window? And what if the application has more than one top level window?
Re: How to determine if my app is active...
then as you said focus events must be helpfull too :)
Main window..em its my miscalculation :o