Weifeng
Weifeng

Reputation: 101

How to remove an menu item from a QMenu for Qt4?

For a QMenu, we can insert two kind of items, one is QAction, which can be removed by removeAction method, the other is another QMenu, I cannot find a way to remove the menu item from a menu.

How to do it? The only way I can think of now is to use clear() method to remove everything and re-generate the items.

Upvotes: 10

Views: 6595

Answers (1)

koan
koan

Reputation: 3686

Get the QAction for the submenu you want to delete:

QAction *menuIdontLike = subMenu->menuAction();
mainMenu->removeAction(menuIdontLike);

Upvotes: 12

Related Questions