Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. macOS menu bar after hiding window
QtWS25 Last Chance

macOS menu bar after hiding window

Scheduled Pinned Locked Moved Unsolved General and Desktop
4 Posts 3 Posters 340 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    equeim
    wrote on 23 Nov 2023, 19:43 last edited by
    #1

    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?

    S M 2 Replies Last reply 23 Nov 2023, 19:51
    0
    • E equeim
      23 Nov 2023, 19:43

      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?

      S Offline
      S Offline
      SGaist
      Lifetime Qt Champion
      wrote on 23 Nov 2023, 19:51 last edited by
      #2

      @equeim Hi,

      One possible way could be to activate Finder. See this stack overflow answer.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      E 1 Reply Last reply 24 Nov 2023, 11:05
      0
      • E equeim
        23 Nov 2023, 19:43

        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?

        M Offline
        M Offline
        mpergand
        wrote on 23 Nov 2023, 21:40 last edited by mpergand
        #3

        Hi @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...

        1 Reply Last reply
        1
        • S SGaist
          23 Nov 2023, 19:51

          @equeim Hi,

          One possible way could be to activate Finder. See this stack overflow answer.

          E Offline
          E Offline
          equeim
          wrote on 24 Nov 2023, 11:05 last edited by
          #4

          @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 Reply Last reply
          0

          1/4

          23 Nov 2023, 19:43

          • Login

          • Login or register to search.
          1 out of 4
          • First post
            1/4
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved