JasonGenX
JasonGenX

Reputation: 5444

Qt: Weirdness with Mac MenuBars

I observe a strange behavior with regards to Qt 4.7.4 running on OSX Lion.

I'd like my application to have a single menubar for all windows. so, my application holds and initializes a QMenuBar object:

this->macMenuBar = new QMenuBar(0);

When I run my application, I see my application's name on the menu bar, right to the apple logo, with some default options like Quit, Services-> etc...

I'd like to add two new options to this menu (under my application's name). So I try to do this in the QApplication's constructor.

this->macMenuBar->addAction(configurationAction);
this->macMenuBar->addAction(aboutMyAppAction);

This has no effect on the menu. It won't show my items, although both Actions are valid and working from the dock icon menu)

Then, I decide something that doesn't make sense at all, but works partially.

QMenu * menu = this->macMenuBar->addMenu(("blah blah"));
menu->addAction(configurationAction);
menu->addAction(aboutMyApp);

Now my two actions, "configuration", and "about" will show, and there's no trace of any menu item called "blah blah" under which those actions are supposed to appear!

Now I decide to add another line:

menu->addAction(loginAction);

So what Do I get now? "preferences" and "about" in the menu underneath my application name's menu item, AND a new sub-menu called "blah blah" to its right, with one item only, my loginAction.

I am really confused here.

  1. Why am I not getting the "blah blah" top level menu item until I add a third action?

  2. How can I force my "loginAction" into the first top level menu, under my application's name?

Upvotes: 1

Views: 1797

Answers (1)

JasonGenX
JasonGenX

Reputation: 5444

Issue resolved in the Qt forum: http://developer.qt.nokia.com/forums/viewthread/14610/

Upvotes: 1

Related Questions