Show/hide top-level submenu at runtime
General and Desktop
3
Posts
2
Posters
4.1k
Views
1
Watching
-
In my application, I want to dynamically show or hide top-level submenus at runtime. To do so, we use QWidget::setVisible() as QMenu is derived from QWidget after all. Unfortunately, it does not work. Our code looks like this:
In mainwindow.h:
@
QMenu *helpMenu;
QAction *actionHelpAbout;
@In mainwindow.cpp:
@
actionHelpAbout = new QAction(tr("&About"), this);
helpMenu = menuBar()->addMenu(tr("&Help"));
helpMenu->addAction(actionHelpAbout);
helpMenu->setVisible(false);
@[EDIT: code formatting, please wrap in @-tags, Volker]