The setMenuRole function is a member of the QAction class in C++. This function sets the menu role of the QAction to the specified value. The menu role determines the type of action that should be displayed in a menu. The possible roles are Default, NoRole, TextHeuristicRole, ApplicationSpecificRole, AboutQtRole, and AboutRole.
Example 1: Setting the menu role to AboutQtRole
QAction *aboutQt = new QAction("About Qt", this); aboutQt->setMenuRole(QAction::AboutQtRole);
This example creates a new QAction called "About Qt" and sets its menu role to QAction::AboutQtRole. This will cause the action to be displayed in the "About Qt" submenu of the help menu.
Package Library: QT Library
Example 2: Setting the menu role to ApplicationSpecificRole
QAction *myAction = new QAction("My Action", this); myAction->setMenuRole(QAction::ApplicationSpecificRole);
This example creates a new QAction called "My Action" and sets its menu role to QAction::ApplicationSpecificRole. This will cause the action to be displayed in a custom submenu of the menu where it is added.
Package Library: QT Library
C++ (Cpp) QAction::setMenuRole - 30 examples found. These are the top rated real world C++ (Cpp) examples of QAction::setMenuRole extracted from open source projects. You can rate examples to help us improve the quality of examples.