title: QT run objective-c code
body: <p>I'm trying to run native object-c code on my Mac application.</p>
  
  <p>My code looks like:</p>
  
  <p><strong>MainWindow.h:</strong></p>
  
  <pre><code>#ifdef Q_OS_MAC
      #include &lt;Carbon/Carbon.h&gt;
      #include &lt;ctype.h&gt;
      #include &lt;stdlib.h&gt;
      #include &lt;stdio.h&gt;
  
      #include &lt;mach/mach_port.h&gt;
      #include &lt;mach/mach_interface.h&gt;
      #include &lt;mach/mach_init.h&gt;
  
      #include &lt;IOKit/pwr_mgt/IOPMLib.h&gt;
      #include &lt;IOKit/IOMessage.h&gt;
  #endif
  </code></pre>
  
  <p><strong>MainWindow.cpp:</strong></p>
  
  <pre><code>MainWindow::MainWindow(QWidget *parent) :
      QMainWindow(parent),
      ui(new Ui::MainWindow)
  {
      ui-&gt;setupUi(this);
  
  
      #ifdef Q_OS_MAC
      [[[NSWorkspace sharedWorkspace] notificationCenter] addObserver: self
              selector: @selector(receiveSleepNote:)
              name: NSWorkspaceWillSleepNotification object: NULL];
      #endif
  
  }
  
  #ifdef Q_OS_MAC
  - (void) receiveSleepNote: (NSNotification*) note
  {
      NSLog(@"receiveSleepNote: %@", [note name]);
  }
  #endif
  </code></pre>
  
  <p>But am getting errors that seems that QT does not understand the code structure:</p>
  
  <blockquote>
    <p>application.cpp: error: expected external declaration
    - (void) receiveSleepNote: (NSNotification*) note ^</p>
  </blockquote>