[Qt-interest] How does one dynamically modify a menu?

Oliver.Knoll at comit.ch Oliver.Knoll at comit.ch
Mon Feb 7 10:16:34 CET 2011


On 2011-02-07 Noam noam.rosenthal at nokia.com wrote:

> QMenu does have a removeAction method, though it doesn't appear in the 
> doc since it's not overloaded from QWidget.

If you really want to *remove* a menu entry simply deleting the corresponding QAction is enough: the QObject meta-system will automatically make sure that the given QObject (the QAction) is unregistered from its parents (aka "owners") which happens to the the QMenu. So the menu entry is removed for you.

If you want to *change* an existing menu entry you can use the usual QAction#setText() etc. method and disconnect/reconnect the QAction as needed.

Cheers, Oliver
--
Oliver Knoll
Dipl. Informatik-Ing. ETH
COMIT AG - ++41 79 520 95 22





More information about the Qt-interest-old mailing list