'QT/C++ on MAC - How do I hide my dock icon?

I'd like my dock icon to be hidden and the app to be represented as a menu bearing icon on the menu bar (right hand side).



Solution 1:[1]

The alternative answer is by using TransformProcessType() to show/hide dock icon dynamically in code.

#import <Foundation/Foundation.h>

void toggleDockIcon(bool show) {
  ProcessSerialNumber psn = {0, kCurrentProcess};
  if (show) {
    TransformProcessType(&psn, kProcessTransformToForegroundApplication);
  } else {
    TransformProcessType(&psn, kProcessTransformToUIElementApplication);
  }
}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Alfi Maulana