From what i understood from the internet resources, I could create a Popup menu of QActions
on the Qtoolbar
by using Qtoolbuttonpopup
mode.
So, I created a QMenu
and added a few QActions
to it by using QMenu.addAction
.
After that i have created a QToolButton
and set the ToolButtonPopupMode
to 2
. Followed by setting the QMenu
i have created above as the menu for it by using .setMenu(QMenu)
SettingMenu = QtGui.QMenu()
SettingMenu.addAction(Action1)
SettingMenu.addAction(Action2)
SettingButton = QtGui.QToolButton()
SettingButton.setIcon(QtGui.QIcon(QtGui.QPixmap(':/setting.png')))
SettingButton.ToolButtonPopupMode(2)
SettingButton.setMenu(SettingMenu)
from the above code, i am expecting to have a Qtoolbutton
on my toolbar and when i click on it, it should pop up a menu with 2 Actions. But when i run the code, all i see is a Qtoolbutton
on my toolbar but when i click the Qtoolbutton
it doesn't create any pop up menu.
Am i doing this wrong? How do i create a toolbutton that create a pop up menu of actions upon user click?