It depends a lot on the context you're in. If you have created a custom Qt 
button and you want to give it a right-click menu, a lot of the time you 
have to do something like this in the __init__ function:

self.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
self.customContextMenuRequested.connect(self.showCustomContextMenu)

and then write your own showCustomContextMenu(self, point) function that 
creates a QMenu and assigns QActions to it, then shows the menu using 
something like 

menu.popup(self.mapToGlobal(point))


If you're accessing your widget through maya.cmds, or you're trying to add 
a right-click menu to existing Maya controls it would be different.

If your button is a QPushButton, note that you can use setMenu() to give it 
a little drop-down menu with an arrow (see here 
<https://doc-snapshots.qt.io/qtforpython/PySide2/QtWidgets/QPushButton.html#PySide2.QtWidgets.PySide2.QtWidgets.QPushButton.setMenu>),
 
which might be simpler and friendlier.

On Tuesday, 16 October 2018 15:17:10 UTC+11, Adam Baker wrote:
>
> Hey all, 
>
> I am new to using Qt to design UI’s, as my only background is using 
> maya.cmds. I am slowly learning that you able todo a lot of  complex 
> things, but with that it creates a larger learning curve.   
>
> I am trying to learn how to recreate the maya - cmds.popupMenu() [this is 
> a right click menu on a button] using only qt to allow me to add; 
> buttons,checkboxes , radial collectives and text fields inside this pop up 
> menu. 
>
>
> Any information would be greatly appreciated 
>
> - Adam B 

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to python_inside_maya+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/eeba863b-d67c-4703-8198-920097d5711c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to