Reputation: 3553
For some reason all my menu bar items are greyed out when I use the native menu bar on OS X Mavericks:
I create the menu actions using the following code:
newAct = new QAction(tr("&New"), this);
newAct->setShortcuts(QKeySequence::New);
newAct->setStatusTip(tr("New"));
newAct->setShortcutContext(Qt::ApplicationShortcut);
newAct->setEnabled(true);
newAct->setAutoRepeat(false);
addAction(newAct);
connect(newAct, SIGNAL(triggered()), this, SLOT(newFile()));
...
These actions are then added to the menubar like this:
// _menuBar = new QMenuBar(0);
_menuBar = menuBar();
//_menuBar->setNativeMenuBar(false);
fileMenu = _menuBar->addMenu(tr("&File"));
fileMenu->addAction(newAct);
Uncommenting the first line shows the same behaviour. It does however work fine when I use the the non-native menu bar.
Qt version:
$ /usr/local/qt/5.3/clang_64/bin/qmake -v
QMake version 3.0
Using Qt version 5.3.1 in /usr/local/qt/5.3/clang_64/lib
Any ideas/suggestions?
Upvotes: 0
Views: 356
Reputation: 1
I had the same problem.
Setting the windowModality
property of my MainWindow to NonModal
worked for me.
Upvotes: 0
Reputation: 73294
I suspect this line is your culprit:
addAction(newAct);
You shouldn't be adding the QActions to your window, since you'll be adding them to the fileMenu object instead. Try removing the above line.
Upvotes: 0