Important: Please read the Qt Code of Conduct -

Using an existing QAction object in a menu with Qt Creator

  • Hello,

    I would like to use an existing QAction that I have instantiated and manipulating it (e.g.: settings some of its properties) in some part of my application and then insert it in a menu bar created through the wysiwyg tools of Qt Creator.

    Let's say the QAction is named myAction
    QAction *myAction = new QAction(tr(&Act and Play));


    I've tried to add it to a menu created with the wysiwyg menu editor of Qt Creator,
    but it the action is appended at the end of the menu, no way to specify its position in the menu.

    Do you know if there is a way to handle this? May be through the metaproperties?


  • Moderators

    If you know the QAction that you want to insert your action before, then you can use "insertAction(),":/doc/qt-4.8/qwidget.html#insertAction which QMenu inherits.

Log in to reply