Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

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.

like image 838
Weifeng Avatar asked Aug 29 '11 18:08

Weifeng


1 Answers

Get the QAction for the submenu you want to delete:

QAction *menuIdontLike = subMenu->menuAction();
mainMenu->removeAction(menuIdontLike);
like image 157
koan Avatar answered Oct 04 '22 23:10

koan