PyQt5 – QActionGroup
QActionGroup : In PyQt5 applications many common commands can be invoked via menus, toolbar buttons, and keyboard shortcuts, since the user expects each command to be performed in the same way, regardless of the user interface used, QAction is useful to represent each command as an action. In some situations it is useful to group QAction objects together, so that user can only select(check) only one QAction at a time just like radio buttons. Also in order to videw the effect og action group the action added to it should be checkable.
Below is how an actions in action group will look inside the menu
action_group = QActionGroup()
This action_group is used by adding those QAction which should lie in same group, they can be added with the help of addAction method. Below are the some frequently used commands with the QAction
addAction : To add QAction to it setEnabled : To make QActionGroup enable or disable setExclusionPolicy : To set exclusion policy to the action group checkedAction : It returns the currently checked action removeAction : To remove the specific QAction from the group actions : It returns the list of QAction group is having
In this we will create a menu bar which will have a menu, and having multiple checkable QAction, below is the implementation
In this we will create a tool bar having multiple QAction which are dived by two action group, below is the implementation