Determining if key is pressed in expression (Python) (PyQT) -


in mousemoveevent method i've seen code below check if either left or right mouse buttons being pushed (as shown below). there way check if keyboard keys being pressed? ideally have action performed when mouse leftclicked , moved , key being pushed. don't see way use keypressevent called separately mousemoveevent (just mousepressevent not used in example).

def mousemoveevent(self, event):     if event.buttons() & qtcore.qt.leftbutton:         #run when mouse moved left button clicked     elif event.buttons() & qtcore.qt.rightbutton:         #run when mouse moved right button clicked 

edit: based on ekhumoro's comment method looks this. works key modifiers:

def mousemoveevent(self, event):     modifiers = qtgui.qapplication.keyboardmodifiers()     if bool(event.buttons() & qtcore.qt.leftbutton) , (bool(modifiers == qtcore.qt.controlmodifier)):         #run when mouse moved left button , ctrl clicked     elif event.buttons() & qtcore.qt.leftbutton:         #run when mouse moved left button clicked                  elif event.buttons() & qtcore.qt.rightbutton:         #run when mouse moved right button clicked 

if able work key response appreciated

def mousemoveevent(self, event):     modifiers = qapplication.keyboardmodifiers()     mmodo = qapplication.mousebuttons()     if bool(mmodo == qtcore.qt.leftbutton) , (bool(modifiers == qtcore.qt.controlmodifier)):         print 'yup' 

Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -