Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
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.
- Developing a Qt App for Mac OS and currently am on OSX 10.7
- 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
- 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.
- The same correct behavior occurs if I select "Hide" from the dock icon too.
- 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?
What version of Qt are you using ?
Anyone has any ideas here ?