[PyQt] Filter mouse move event
Arnold Krille
arnold at arnoldarts.de
Sat Apr 4 20:09:15 BST 2009
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: This is a digitally signed message part.
Url : http://www.riverbankcomputing.com/pipermail/pyqt/attachments/20090404/350bfb03/attachment.bin
More information about the PyQt
mailing list