You are not logged in.

Dear visitor, welcome to If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.


Thursday, December 13th 2012, 6:52pm

How to add items to Main Application Menu with Qt on Mac OS X?

I've just started using Qt Creator (4.8.4), under Mountain Lion, and I'm trying to figure out how to put items on the Main Application Menu, such as "Preferences", "About", etc.

How do I add the above options to this macmainwindow sample program (please see attached picture)?

I successfully added other menus, like "File" (please see attached picture), easily with this code:

Source code

QMenu *menu=new QMenu(0);menu = menuBar()->addMenu(tr("&File"));

And I know I'm supposed to use (but how, in **macmainwindow** menu?):

Source code

QMenuBar *menuBarMac = new QMenuBar(0);

Thanks a lot for your help!
neowinston has attached the following file:
  • QtCreatorMac.png (66.22 kB - 13 times downloaded - latest: Sep 8th 2016, 12:36am)


Thursday, December 13th 2012, 8:30pm

I found the solution!

I just used this code, and it worked fine:

Source code

     QMenu *helpMenu = new QMenu(tr("&Help"), this);
     QAction *aboutAction = helpMenu->addAction(tr("&About"));
     connect(aboutAction, SIGNAL(triggered()), this, SLOT(showAboutBox()));