[PyKDE] Reimplementing QApplication.notify

Phil Thompson phil at river-bank.demon.co.uk
Fri Nov 29 21:54:01 GMT 2002


On Friday 29 November 2002 8:36 pm, Konrad Hinsen wrote:
> A rather annoying feature of Qtopia applications is that they are
> terminated whenever the user presses the Esc key. On the Zaurus
> developer list, I got the tip that this feature could only be disabled
> by reimplementing QPEAppliction.notify, as no lower level ever gets to
> see the key press event. So I tried
>
>    class MyApplication(QPEApplication):
>
>        def notify(self, receiver, event):
> 	   if event.type() == QEvent.KeyPress and event.key() == Qt.Key_Escape:
> 	       pass
> 	   else:
> 	       return receiver.event(event)

            return QPEApplication.notify(self,receiver,event)

might improve things.

>    app = MyApplication(sys.argv)
>
> but got nothing but the error message
>
>    RuntimeError: No access to protected functions or signals for object
>                  not created from Python
>
> for the call to receiver.event(event).
>
> Is there any way around this?

Difficult to say with an incomplete code fragment. Are you calling the 
QPEApplication ctor?

Phil




More information about the PyQt mailing list