eduardo simioni

pyqt

right click signal in PyQt/PySide

by on Jun.10, 2014, under Maya, MotionBuilder, pyqt, pyside, python

It’s extremely easy, if you know it’s called customContextMenuRequested:

http://qt-project.org/doc/qt-4.8/qwidget.html#customContextMenuRequested

As for example:

btnLeft.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
btnLeft.customContextMenuRequested.connect( lambda: self.RMB(btnLeft, oModel) )

It also has QPoint as default value returning the pixel where right click/contextMenu was requested:

btnLeft.setContextMenuPolicy(QtCore.Qt.CustomContextMenu)
btnLeft.customContextMenuRequested.connect( self.asd )

def asd(self, pos)
    print pos
Leave a Comment :, , , , , , more...

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!