Search code examples
qtqmenu

Is it possible to respond to a click on a tiop level menu item?


Is it possible to respond to a click on a top level menu item? For example, referring to the image below, is it possible to run code when the "Help" menu item is clicked?

Simple menu picture

If so, how do I do that?

Thank you.


Solution

  • You can use QMenu::aboutToShow() signal and do the following:

    connect(helpMenu, SIGNAL(aboutToShow()), this, SLOT(onHelpMenuClicked()));
    

    where helpMenu is pointer to your Help menu and onHelpMenuClicked() is slot that will be called as soon as you click on the Help menu.