Important: Please read the Qt Code of Conduct -

Add Menu Item from QUndoStack

  • Hi all,
    I have hooked up the QUndoStack in my code. I would like to Add the Undo and Redo Menu items as created by createUndoAction and createRedoAction [link text( into my application menubar. This menubar was created in the designer. When I try to add the actions with menuBar()->insertAction(before, undo action) they end up as a main menu item add the end of the menu bar. So it is not inserting at all. Can somebody please explain me how this is supposed to work? thanks.

  • I'll answer myself, I am embarrassed to say it was quite easy. Because the insertAction only works on the action list of one widget it is not meant to be used on the menubar directly. Instead this just has to be used on the QMenu child items directly. I had no idea how to get to them until I realized that they just have names as shown in the designer. So I gave m decent names and I call it directly. So I you have a menu Item named menuEdit. It will work correctly when calling menuEdit->insertAction.....

Log in to reply