title: Register Global Hotkey under Qt and Mac OS X
body: <p>Having read through various posts and threads that lead me nowhere I need your help.</p>
  
  <p>I do have a Qt Application for Mac OS X that at some point of use will be in the background and not active. When this is the case I want to add a global hotkey so that the user can easily turn certain features on or off by clicking pre-defined hotkeys.
  The following isn't working while the app is in the background and not focused.</p>
  
  <pre><code>QShortcut *shortcut = new QShortcut(QKeySequence(Qt::Key_F12), parent);
  shortcut-&gt;setContext(Qt::ApplicationShortcut);
  </code></pre>
  
  <p>So far I found <code>Qxt</code> which happens to be outdated for Qt 5.5.
  Then there is DDHotkey which requires a certain compiler which we can not use for various reasons.
  Lastly, I found the solution of adding a global <code>AppleScript</code> which registers an event, again, not what I am looking for.</p>
  
  <pre><code>tell application "System Events" to tell process "myApp"
      click menu item "myButton" of menu 1 of menu bar item "Menu" of menu bar 1
  end tell
  </code></pre>
  
  <p>Is there a way to use <code>objective-c</code> or <code>cocoa</code> to accomplish exactly what I am looking for?
  Please lead me in the right direction if I may have missed something.</p>
  
  <p>Thanks in advance!</p>
  
  <hr>
  
  <p>To those who seek a more Qt way, check the following repository:
  <a href="https://github.com/ddqd/qxtglobalshortcut5" rel="nofollow noreferrer">https://github.com/ddqd/qxtglobalshortcut5</a></p>
  
  <p>It makes use of the <em>outdated</em> <code>qxt</code> library but gets it working again.
  The person tested it until Qt 5.4, we use it successfully under Qt 5.5.</p>