c++qtqt-designerqactionqmenubar

How to add action to QAction when clicked


I just created a simple app using Qt and Qt Designer and added a QMenuBar with a menu.

How can I make it so certain code will be executed if a QAction Element is triggered?

MenuBar with QActions


Solution

  • You can use Qt Designer's Action Editor, where you can find all the actions you added to your form, and edit them.

    In you case, you can do the following in your action editor:

    Here's an example:

    Action editor in Qt Desginer