无法隐藏QMenu对象QMenu :: setVisible()? [英] Not possible to hide a QMenu object QMenu::setVisible()?

查看:392
本文介绍了无法隐藏QMenu对象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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆