[Qt-interest] How does one dynamically modify a menu?
K. Frank
kfrank29.c at gmail.com
Mon Feb 7 02:23:34 CET 2011
Hello All!
How can I replace one menu with another at run time? (Alternatively,
how can I replace menu items in a menu?)
I see that QMenuBar has an addMenu function and QMenu has an
addAction function, but they have neither a removeMenu nor a a
removeAction function, respectively.
My use case is that I would to have a normal menu in the menu bar
of a QMainWindow (for example, the File menu) be displayed in two
different forms, depending on context.
The lack of the remove functions seems to be the show-stopper.
(Note, that show, hide, and setVisible do not do the right thing.)
Lastly, ideally, I would like to be able to set as much of the menus
up as possible with Qt Designer. For example, it's very easy to use
Designer to create a menu bar that has both a File1 and a File2 menu.
If only I could programmatically hide either File1 or File2, I'd be home
free. But I haven't found any functions that will let me do that.
Any suggestions?
Thanks.
K. Frank
More information about the Qt-interest-old
mailing list