tags:

views:

49

answers:

1

I can find no non-deprecated way of hiding an item in a menu bar in Qt4.

This post: http://qt.nokia.com/developer/faqs/585 gives a method that uses deprecated Qt3 compatibility functions.

Is there a better way?

+3  A: 

QAction::setVisible() is what you are looking for:

QAction* act = new QAction(tr("&Moo"), this);
someMenu->addAction(act);

// ...

act->setVisible(false);

To apply that to menus use their QAction* which you get either via QMenu::menuAction() or from QMenu::addMenu() (depending on what overload you use).

Georg Fritzsche
I want to remove a *Menu*, not a menu *item*. If I understand correctly, an Action is a menu item, something you can click on directly.
static_rtti
I thought you wanted to *hide* an *item*? That what your question says. Besides, `addMenu()` or `QMenu::menuAction()` returns you a `QAction*` which you can use to hide it.
Georg Fritzsche
I said "hide an item in a *MenuBar*", but maybe that wasn't clear enough.In any case, thanks, I'll look into it.
static_rtti
Thanks! That solved it!
static_rtti