在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:
>
> 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);
原文连接:
本文介绍了在Qt中如何正确地隐藏一个菜单项。通常情况下,直接调用QMenu::hide()并不能达到预期效果。正确的做法是通过QMenu::menuAction()->setVisible(false)来隐藏与菜单关联的QAction,从而实现菜单的隐藏。
784

被折叠的 条评论
为什么被折叠?



