PDA

View Full Version : RubberHandDrag doesn't work !



Qtdigitex
14th July 2016, 14:33
Hello , i'm using PYQT 4

i designed a litte application ( QMainWindow ) in QtDesigner and used pyuic to get the python code for the interface.

in my main script : because i wanted the mouse related Events to work Only in the QGraphicsView zone , i reimplemented the fonctions like this :

self.graphicsView.mousePressEvent = self.myPressEvent / self.mouseReleaseEvent = self.myReleaseEvent ... etc

normally i have set the QgraphicsView's DragMode to : ' RubberHandMode' but it doesn't work because of the way i reimplemented the event functions !!
i don't even see what's the relation between both of them ? !

whenever i delete the lines of reimplementation (mentioned above) , it works again normally ( i've found this after hours looking for the problem :( .. )

Also , if i write normal methods in my main class : def mousePressEvent(self,event ) .. the event works on all the QMainWindow and don't want this and the rubberHandMode works normally .

am i doing things in a wrong way ? !

Thanks for reading ,

Qtdigitex
14th July 2016, 17:05
SrollHandDrag also doesn't work , whenever i remplement a Mouse related Event as mentioned in the first post

Qtdigitex
14th July 2016, 21:37
Problem resolved : i needed to give the control back ( for each Event ) to the QGraphicsView in myPressEvent method after setting the DragMode inside it , by writing
QGraphicsView.mousePressEvent(self.graphicsView,ev ent)

that was my mistake !