在Qt中,直接使用QMenu::hide()是不会隐藏这个菜单的,想要隐藏菜单,因为每个菜单都是与QAction联系起来的,所以使用QMenu::menuAction()->setVisible(false),这样,就可以把这个菜单隐藏起来。
> The menu is represented in the menu bar using a QAction. In order to
> hide the menu "menuTest1" you have to hide its associated action. You
> can access that action using QMenu::menuAction(), like this:
>
> menuTest1->menuAction()->setVisible(false);