Not possible to hide a QMenu object QMenu::setVisible()?

最后都变了- 提交于 2019-12-08 15:53:45

问题


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:

File - Edit - SuperHeavyExpertMenus - Settings - Help

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.

I want to show that sub tree with SuperHeavyExpertMenu, when a checkbox in Settings is true, for instance.

I can hide the children QActions of the QMenu s above, vie QAction:setVisible(false) . but I can do that for the QMenu ?

Is there a way to hide the QMenu ?


回答1:


If I understood correctly your problem, the way you can solve it is whit something like this:

ui->menuYouWantToHide->menuAction()->setVisible(false);

I hope to be useful.




回答2:


Qmenu doesn't have setVisible(), or hide(), but you can change the title instead:

ui->MenuYouWantToHide->setTitle("");

This will remove the title, and therefore the "Action" that make up the button in your GUI.



来源:https://stackoverflow.com/questions/32375691/not-possible-to-hide-a-qmenu-object-qmenusetvisible

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!