Hide main window versus Command-H on macos



  • Hi, Am a relative newbie to both Qt and Mac and am faced with a problem for which I have exhausted all my attempts to find a resolution.

    Here is my situation.

    1. Developing a Qt App for Mac OS and currently am on OSX 10.7
    2. A requirement for the app is to hide the app when clicked on the "close" button, and it can be accessed anytime by clicking on the system tray icon that the app installs when it is run
    3. When the app is launched, and I hit the Command-H menu item, the app window gets hidden. Now, if I relaunch the app again by double-clicking on the .app, it comes to the foreground as expected.
    4. The same correct behavior occurs if I select "Hide" from the dock icon too.
    5. However, I run into problems when I try hide from the application itself programmatically i.e. when clicking on the "close" button on the title bar. The window is correctly hidden. However, if I try to relaunch the app, it is not appearing. What I have tried is the following:
      a. I simply do a setProperty("visible", false) on the main window when clicked on "close"
      b. I do a NSRunningApplication hide
      c. I do both a and b

    None of these work.

    What I would like to know is how I can simulate a Command-H trigger programmatically. This is because, I know that the chain of events that happen when I do a Command-H results in correct behavior.

    Could someone give me some pointers?

    Thanks!


  • Lifetime Qt Champion

    Hi,

    What version of Qt are you using ?



  • Version 5.4



  • Anyone has any ideas here ?


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.