[PyKDE] event filters

Phil Thompson phil at riverbankcomputing.co.uk
Wed Oct 15 19:16:01 BST 2003


On Wednesday 15 October 2003 5:54 pm, Toby Dickenson wrote:
> On Wednesday 15 October 2003 17:46, Phil Thompson wrote:
> > On Wednesday 15 October 2003 5:40 pm, Toby Dickenson wrote:
> > > Im not seeing event filters work how I expected. In the following
> > > script I am seeing the 'event' line but *never* the 'filter' line. PyQt
> > > 3.8, qt 3.1.2, on windows and X.
> > >
> > > Any ideas? Thanks in advance.
> > >
> > > from qt import *
> > >
> > > class F(QObject):
> > >     def eventFilter(self,ob,ev):
> > >         print 'filter',ob,ev,'but Ive never seen this working'
> > >         return 0
> > >     def event(self,ev):
> > >         print 'event',ev
> > >         return 0
> > >
> > > app = QApplication([])
> > >
> > > f1 = F()
> > > f2 = F()
> > > f1.installEventFilter(f2)
> > >
> > > app.sendEvent(f1,QCustomEvent(QEvent.User))
> >
> > You aren't calling QObject.__init__().
>
> On my two instances of the class F?
>
> Im not calling __init__, but python will do when I create the instances
> surely.
>
> I dont think Im missing anything that fundamental.

Sorry, force of habit.

See what happens if you comment out the event() method.

Phil




More information about the PyQt mailing list