You have 3 different ways to show a context menu, depending on the level of 
control you want:
ContextMenuPolicy-enum<http://doc.qt.digia.com/qt/qt.html#ContextMenuPolicy-enum>

Qt::DefaultContextMenu1the widget's 
QWidget::contextMenuEvent<http://doc.qt.digia.com/qt/qwidget.html#contextMenuEvent>()
 
handler is called.Qt::ActionsContextMenu2the widget displays its 
QWidget::actions <http://doc.qt.digia.com/qt/qwidget.html#actions>() as 
context menu.Qt::CustomContextMenu3the widget emits the 
QWidget::customContextMenuRequested<http://doc.qt.digia.com/qt/qwidget.html#customContextMenuRequested>()
 
signal.
So this means that you can use the default context menu, and define the 
contextMenuEvent() on a subclass of your button to display a menu that you 
create.
Or you can just add the actions you want for the context menu to the button 
using 
addActions(actionList)<http://qt-project.org/doc/qt-4.8/qwidget.html#addActions>,
 
and set the actions context menu flag.
Or you can handle your context menu in a completely separate slot, and just 
set custom context menu, then connect the signal.

The first and last option require you to create a menu and exec_() it. The 
middle option just requires that you set your desired QAction's on the 
button.

 


On Tuesday, December 4, 2012 8:27:43 AM UTC-8, Rishis3D wrote:
>
>  context menu that happens only on right click
>

-- 
view archives: http://groups.google.com/group/python_inside_maya
change your subscription settings: 
http://groups.google.com/group/python_inside_maya/subscribe

Reply via email to