PDA

View Full Version : PyQt4 doesn't execute eventFilter()



akiross
29th October 2008, 01:18
Hello there,
I'm working with PyQt and trying to filter an event, but it doesn't seem to work. I wrote a simple test (which seems correct to me), but doesn't work too.

Here the code:

#!/usr/bin/python

import sys
from PyQt4.QtGui import *
from PyQt4.QtCore import *

class SomeFilter(QObject):
def eventFilter(self, obj, ev):
print("Event filtering ok")
return False

class MainWidget(QMainWindow):
def __init__(self):
QMainWindow.__init__(self)
self.installEventFilter(SomeFilter())

app = QApplication(sys.argv)
w = MainWidget()
w.show()
sys.exit(app.exec_())

The print is never executed (on loading, resizing, repainting and closing)

Am I doing this wrong?
Thanks