title: Menubar is only shown after app/desktop switch on MacOS using Qt5
body: <p>Using the following example code the native menu on MacOS 10.9.5 using Qt 5.3.2 does not show up when starting the application. The former menu remains visible but no actions can be performed with this toolbar. If I switch to another application or to another desktop, the menu of this application becomes visible and usable as expected.</p>
  
  <p>My questions is pretty much the same as the following one, but the answer does not work for my code:</p>
  
  <p><a href="https://stackoverflow.com/questions/21744411/qt-menubar-not-showing">Qt menubar not showing</a></p>
  
  <p>There is another very similar question here and I already modified my code according to the suggested answer, but it does not work either:</p>
  
  <p><a href="https://stackoverflow.com/questions/25261760/menubar-not-showing-for-simple-qmainwindow-code-qt-creator-mac-os">MenuBar Not Showing for Simple QMainWindow Code, Qt Creator Mac OS</a></p>
  
  <pre><code>#include &lt;QtGui&gt;
  #include &lt;QtWidgets&gt;
  
  class MainWindow : public QMainWindow
  {
  public:
      MainWindow();
  
  private:
      void create_actions_();
      void create_menus_();
      void about_();
      void dummy_();
  
      QMenuBar* menu_bar_;
      QMenu* file_menu_;
      QMenu* help_menu_;
      QAction* action_about_;
      QAction* action_dummy_;
  };
  
  MainWindow::MainWindow()
  {
      resize(800, 600);
  
      create_actions_();
      create_menus_();
  }
  
  void MainWindow::create_actions_()
  {
      action_about_ = new QAction(tr("About"), this);
      action_dummy_ = new QAction(tr("Dummy"), this);
      connect(action_about_, &amp;QAction::triggered, this, &amp;MainWindow::about_);
      connect(action_dummy_, &amp;QAction::triggered, this, &amp;MainWindow::dummy_);
  }
  
  void MainWindow::create_menus_()
  {
      menu_bar_ = new QMenuBar(this);
  
      file_menu_ = new QMenu(tr("&amp;File"));
      file_menu_-&gt;addAction(action_dummy_);
      menu_bar_-&gt;addAction(file_menu_-&gt;menuAction());
  
      help_menu_ = new QMenu(tr("&amp;Help"));
      help_menu_-&gt;addAction(action_about_);
  
      menu_bar_-&gt;addAction(help_menu_-&gt;menuAction());
  
      menu_bar_-&gt;setNativeMenuBar(true);
  }
  
  void MainWindow::about_()
  {
      QMessageBox::about(this, tr("About"), tr("FooBar"));
  }
  
  void MainWindow::dummy_()
  {
      QMessageBox::about(this, tr("Dummy"), tr("Dummy"));
  }
  
  int main(int argc, char **argv)
  {
      QApplication app(argc, argv);
  
      MainWindow main_window;
      main_window.show();
  
      return app.exec();
  }
  </code></pre>
  
  <p>I am really sorry that I bring up the same question again, but I am not allowed to make any comments as a newbie (which frankly sucks!).</p>
  
  <p>Edit:
  I'm using the following CMake file to build the test project:</p>
  
  <pre><code>cmake_minimum_required(VERSION 2.8.12)
  project(testproject)
  
  set(CMAKE_INCLUDE_CURRENT_DIR ON)
  set(CMAKE_AUTOMOC ON)
  
  find_package(Qt5Widgets)
  add_executable(testapp main.cpp mainwindow.h mainwindow.cpp)
  target_link_libraries(testapp Qt5::Widgets)
  </code></pre>