[PyQt] eventFilter not executed

Phil Thompson phil at riverbankcomputing.com
Wed Oct 29 16:03:36 GMT 2008


On Wed, 29 Oct 2008 15:58:16 +0000, "Alessandro Re"
<akirosspower at gmail.com> wrote:
> I hate double-posting, but i guess here it's a more appropriate place
> where to ask
>
(http://www.qtcentre.org/forum/f-newbie-4/t-pyqt4-doesnt-execute-eventfilter-16734.html)
> 
> I'm trying to filter some events, but it seems that eventFilter()
> isn't executed in the filter object.
> I did this example and the message is never printed
> 
> #!/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_())
> 
> Am I using this in the wrong way?

Your filter object is being immediately garbage collected.

Phil


More information about the PyQt mailing list