Add Menu Item from QUndoStack
-
wrote on 31 Mar 2015, 14:08 last edited by
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(http://doc.qt.io/qt-5.4/qundostack.html#createRedoAction) 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. -
wrote on 31 Mar 2015, 14:32 last edited by
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.....
1/2