Qt: 隐藏菜单QMenu

来源:互联网 发布:华为文化 知乎 编辑:程序博客网 时间:2024/05/16 11:53

转自:http://www.cppblog.com/biao/archive/2009/09/16/96467.html

在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);

原创粉丝点击