Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct

    Add Menu Item from QUndoStack

    General and Desktop
    1
    2
    364
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Richard
      Richard 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.

      1 Reply Last reply Reply Quote 0
      • Richard
        Richard 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 Reply Last reply Reply Quote 0
        • First post
          Last post