tags:

views:

182

answers:

2

Hello,

I'm having difficulties to make a QMenuBar display a QMenu with a QAction under Mac OS X (Snow Leopard).

Here is the code I'm using for creating the menu:

void ClientWindow::setUpMenu ()
{
   QMenu * file = menuBar()->addMenu("&File");
   QAction * quit = new QAction("&Quit", this);
   file->addAction(quit);

   connect(quit, SIGNAL(triggered()), this, SLOT(quit()));
}

Here is the ClientWindow class interface:

class ClientWindow : public QMainWindow
{
    public:
        ClientWindow (QWidget * parent = 0);
        void setUpMenu ();
};

And here is my main() method:

int main (int argc, char * argv[])
{
    QApplication app(argc, argv);
    ClientWindow window;

    window.setUpMenu();
    window.show();

    return app.exec();
}

Any ideas why it wouldn't show up on the menu bar? Thank you all.

+2  A: 

I solved the problem.

It appears that there is one action called "Quit" already, which is part of the default application's menu (every Mac OS X GUI app has such menu). This causes my attempt to add another action called "Quit" to be ignored by either Qt or the Window Server.

Simply renaming the action to "Close" solved the problem.

Erick
A: 

Some menupoints are automatically mapped to the mac osx native menu:

see http://doc.trolltech.com/4.6/mac-differences.html#menu-bar

dape82