...
The qsetmenu command assigns a qmenu to a widget or tree item.
...
The target widget to receive the action object. This must be an qaction, qpushbutton, qtoolbutton, or qtreewidget. If the widget is a QTreeWidget the menu will appear when the user clicks on the tree background.
...
The menu to be assigned. This must be an instance of qmenu.
itemtype
The tree widget item type. This is an integer corresponding the type parameter supplied in the qtreewidgetitem command. The menu will be a right-click menu for all items having this type.
Examples
See qmainwindow for examples on how to use the qsetmenu command.