illunara

EventFilter

Apr 19th, 2013
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.79 KB | None | 0 0
  1. self.GraphicsView.installEventFilter(self)
  2.  
  3. self.GraphicsView.mousePressEvent = self.qView_mousePressEvent
  4.  
  5. def eventFilter(self,obj,event):
  6.     if obj is self.GraphicsView:
  7.         if event.button() != QtCore.Qt.LeftButton:
  8.             self.qView_mousePressEvent(event)
  9.                 return True
  10.     return super(RigModuleUi, self).eventFilter(obj, event)
  11.  
  12. def qView_mousePressEvent(self,event):
  13.     if (app.keyboardModifiers() == QtCore.Qt.AltModifier  and event.button() == QtCore.Qt.MiddleButton):
  14.         self.GraphicsView.setCursor(QtCore.Qt.SizeAllCursor)   
  15.     if (app.keyboardModifiers() == QtCore.Qt.AltModifier  and event.button() == QtCore.Qt.RightButton):
  16.         self.GraphicsView.setCursor(QtCore.Qt.SizeVerCursor)
  17.     if event.button() == QtCore.Qt.LeftButton:
  18.         QtGui.QGraphicsView.mousePressEvent(self.GraphicsView, event)
Advertisement
Add Comment
Please, Sign In to add comment