I have an issue that I cannot raise my app Window when it got hidden with MacOS shortcut. It work correctly in all other cases.
In my app i have 1 main qWindow called
QWindow* mMainWindow;
and following code added to tray button
mMenu->addAction(createAction("Show", [=] {
if (mMainWindow) {
mMainWindow->show();
mMainWindow->raise();
mMainWindow->requestActivate();
}
When I just use qt mMainWindow->hide()
and then raise it back, mMainWindow
works fine. Method mMainWindow->isActive()
return correct true
state when app is active and false
when it is hidden.
But when I hide app using build-in in mac "cmd + h", mMainWindow->isActive()
return true
regardless if app app is hidden or not. Calling my action item does nothing, mMainWindow
stay all the time hidden.
Is there any solution to fix this issue? I have seen people recommend using QWidget
instead of QWindow
and calling widget->activateWindow()
but it is not solution i can use in my case.
I have discovered that if you call
hide()
before callingshow()
,show()
will behaving correctly.Workaround to this problem is following
there may be issue that when app is already on focus, and you click
Show
it will, hide and show again, but it is acceptable problem in my case.