[PyKDE] Getting control over the Tab key

Konrad Hinsen hinsen at cnrs-orleans.fr
Wed Oct 23 20:29:00 BST 2002


> They may be filtered out by the widget that has focus, it's hard to

At least they never appear in keyPressEvent(), neither for the main
widget nor for the widget in focus.

> tell. If you want to make sure that you catch all the tab key events,
> have a look at QObject::eventFilter() and QObject::installEventFilter().

I tried that, but how does one define an event filter in Python?
Here is what I tried:

  class FilterObject(QObject):

      def eventFilter(self, object, event):
	  sys.stderr.write(repr(object) + ':' + repr(event) + '\n')
	  return 1

  app = QApplication(sys.argv)
  ...
  app.installEventFilter(FilterObject())
  ...
  app.exec_loop()

This doesn't crash, but doesn't do anything either, the event filter routine
is never called.

Konrad.




More information about the PyQt mailing list