You are not logged in.

1

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

1
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

1
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)

2

Thursday, December 13th 2012, 8:30pm

I found the solution!

I just used this code, and it worked fine:


Source code

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