Issue
I am making a application in PySide and I want to click on a toolbutton (which has a custom image) and that would trigger a drop down menu which would have different options. Is there some sort of Widget that does this, or would I have to make a custom one. If yes, how would I do this. I have not tried anything yet, I just need to know how to go about doing it.
Thank you
Solution
It seems u are using the PySide.QtGui.QToolButton widget.
It has a function
YourToolButton.setMenu(menu)
Which associates a menu with the button.You have to pass a QMenu object which you can create just like any other widget.
Use
YourToolButton.setPopupMode(mode)
and set mode to 'InstantPopup' to get instant menu.
To add your options,use
YourMenu.addAction(icon, text, receiver, member[, shortcut=0])
Set the icon and text.The 'receiver' is a function to handle the triggered action. Refer the Pyside Docs.
Answered By - Saurabh7
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.