How can a menu be removed from a menubar?
Answer:
You can remove actions from the menubar using QWidget::removeAction(). See:
http://doc.trolltech.com/4.3/qwidget.html#removeAction
In order to get hold of the action associated with the menu, use QMenu::menuAction(), see:
http://doc.trolltech.com/4.3/qmenu.html#menuAction
The example below demonstrates how this can be done:
#include <QtGui>
class MainWindow : public QMainWindow
{
public:
MainWindow()
{
QMenu *menu = menuBar()->addMenu("Test");
QMenu *menu2 = menuBar()->addMenu("Test2");
menu->addAction("First");
menu2->addAction("Second");
menuBar()->removeAction(menu->menuAction());
}
};
int main(int argc, char **argv)
{
QApplication app(argc, argv);
MainWindow box;
box.show();
return app.exec();
}

