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 *
def eventFilter(self, obj, ev):
print("Event filtering ok")
return False
def __init__(self):
self.installEventFilter(SomeFilter())
w = MainWidget()
w.show()
sys.exit(app.exec_())
#!/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_())
To copy to clipboard, switch view to plain text mode
The print is never executed (on loading, resizing, repainting and closing)
Am I doing this wrong?
Thanks
Bookmarks