macOS menu bar after hiding window
-
wrote on 23 Nov 2023, 19:43 last edited by
Hi.
In my app I have QSystemTrayIcon with "show" and "hide" actions that call QWidget::show() and QWidget::hide() on app's window. The problem is that on macOS after window is hidden the top menu bar still shows menu for my app and it goes away only after I click somewhere (this also happens after I close window via system close button in title bar since I don't destroy window when it's closed. It can be shown again via QSytemTrayIcon menu's "show" action). How to make menu bar switch to the previous app when my app's window is hidden?
-
Hi.
In my app I have QSystemTrayIcon with "show" and "hide" actions that call QWidget::show() and QWidget::hide() on app's window. The problem is that on macOS after window is hidden the top menu bar still shows menu for my app and it goes away only after I click somewhere (this also happens after I close window via system close button in title bar since I don't destroy window when it's closed. It can be shown again via QSytemTrayIcon menu's "show" action). How to make menu bar switch to the previous app when my app's window is hidden?
@equeim Hi,
One possible way could be to activate Finder. See this stack overflow answer.
-
Hi.
In my app I have QSystemTrayIcon with "show" and "hide" actions that call QWidget::show() and QWidget::hide() on app's window. The problem is that on macOS after window is hidden the top menu bar still shows menu for my app and it goes away only after I click somewhere (this also happens after I close window via system close button in title bar since I don't destroy window when it's closed. It can be shown again via QSytemTrayIcon menu's "show" action). How to make menu bar switch to the previous app when my app's window is hidden?
wrote on 23 Nov 2023, 21:40 last edited by mpergandHi @equeim
On Mac, hidding or closing a window don't hide the application.
Looking at QApplication, I see nothing allowing you to do that.
There is a solution by calling NSApp.hide() on Cocoa, but it's a little bit tricky... -
@equeim Hi,
One possible way could be to activate Finder. See this stack overflow answer.
wrote on 24 Nov 2023, 11:05 last edited by@SGaist said in macOS menu bar after hiding window:
One possible way could be to activate Finder. See this stack overflow answer.
That's not exactly what I need since I want to activate previously active app, not Finder.
Calling NSApp.hide seems to work though.
@mpergand said in macOS menu bar after hiding window:
There is a solution by calling NSApp.hide() on Cocoa, but it's a little bit tricky...
What's the tricky part? I don't see any issues at the first glance.
1/4