I have an application on which I show configuration panel (QFrame) to setup the configuration. Now I want to implement functionality where I close the configuration panel if the user clicks anywhere else on my application, but if the user clicks anywhere outside the application, it should not close the application.
Currently I have the following code which works fine on Win 7 but has issues on Mac.
void ConfigurationPanel
::changeEvent ( QEvent * event
) {
if(event
->type
() == QEvent::ActivationChange) {
if(!isActiveWindow())
{
{
close();
}
}
}
}
void ConfigurationPanel::changeEvent ( QEvent * event)
{
if(event->type() == QEvent::ActivationChange)
{
if(!isActiveWindow())
{
if(QApplication::activeWindow())
{
close();
}
}
}
}
To copy to clipboard, switch view to plain text mode
On windows QApplication::activeWindows() returns non-zero value if we click anywhere on the application (but outside configuration panel) and zero value if I click on any other application which is what is expected. But on Mac I always get zero value from QApplication::activeWindow() no matter where I click.
Can anyone tell me how can I fix this issue?
Thanks
Bookmarks