On Saturday 04 April 2009 20:07:35 Luca Fasano wrote:
> Hi list,
> I need to filter mouse moving event on a QGraphicsView. I created a
> filter and install it to a QGraphicsView instance, but desired event
> seems not to be captured.
> Filter definition is:
> class Filter(QtCore.QObject):
>       def eventFilter(self, obj, event):
>       print event.type()
>       return False

Is the indentation in your source-file correct? Because here it looks as if the 
def-line and the print-line are the same indentation level, which would make 
the eventFilter-function an empty function.

> then I have installed an instance of this filter to graphicsview as
> following:
>       self.graphicsview = QtGui.QGraphicsView(self.scene, self)
>       self.graphicsview.setMouseTracking(True)
>       self.filter = Filter(self.graphicsview)
>       self.graphicsview.installEventFilter(self.filter)
>       self.setCentralWidget(self.graphicsview)
> ...but event seems not to be captured! Where I'm wrong??

While your Filter-class subclasses QObject, are you calling QObjects 
constructor from your constructor? As far as I know the constructors of parent 
classes aren't called automaticly in python...

Have fun,

Arnold

Attachment: signature.asc
Description: This is a digitally signed message part.

_______________________________________________
PyQt mailing list    [email protected]
http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Reply via email to