无法隐藏QMenu对象QMenu :: setVisible()? [英] Not possible to hide a QMenu object QMenu::setVisible()?
问题描述
我在应用程序中的MainWindow
顶部建立了QMenu MainMenu
.大家都习惯了,我有以下QMenu
主菜单:
I have built up a QMenu MainMenu
on top of my MainWindow
in my application. As everybody is used to it, I have following QMenu
Main menus:
文件-编辑-SuperHeavyExpertMenus-设置-帮助
File - Edit - SuperHeavyExpertMenus - Settings - Help
我想在程序启动时最初隐藏子树SuperHeaverExpertMenus
,因为它包含很多设置,这可能会使初学者感到困惑.
I would like to hide the sub tree SuperHeaverExpertMenus
initially, on program start, because it conatins a lot of settings, which might confuse beginner users.
例如,当设置"中的复选框为true时,我想用SuperHeavyExpertMenu
显示该子树.
I want to show that sub tree with SuperHeavyExpertMenu
, when a checkbox in Settings is true, for instance.
我可以隐藏上述QMenu
的子级QActions
,竞争QAction:setVisible(false)
.但我可以针对QMenu
吗?
I can hide the children QActions
of the QMenu
s above, vie QAction:setVisible(false)
. but I can do that for the QMenu
?
是否可以隐藏QMenu
?
推荐答案
如果我正确理解了您的问题,解决问题的方法就是这样:
If I understood correctly your problem, the way you can solve it is whit something like this:
ui->menuYouWantToHide->menuAction()->setVisible(false);
我希望会有用.
这篇关于无法隐藏QMenu对象QMenu :: setVisible()?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!