The next widget that is causing me a head-ache, the QListWidget. I never get to catch the key press event in a QListWidget. Reproduce:
moc test2.h -o test2_moc.cpp
g++ -g test2* -I /usr/local/TrollTech/Qt-4.1.0/include -L /usr/local/TrollTech/Qt-4.1.0/lib -lQtGui_debug -lQtCore_debug
test2.h
Qt Code:
  1. #include <QtGui/QtGui>
  2.  
  3. class Test: public QObject
  4. {
  5. Q_OBJECT
  6. public:
  7. bool eventFilter(QObject *o, QEvent *e);
  8. };
To copy to clipboard, switch view to plain text mode 
test2.cpp
Qt Code:
  1. #include "test2.h"
  2.  
  3. void addit(QObject * o, Test * t)
  4. {
  5. o->installEventFilter(t);
  6. foreach (QObject * cobj, o->children())
  7. addit(cobj, t);
  8. }
  9.  
  10. bool Test::eventFilter(QObject *o, QEvent *e)
  11. {
  12. if (e->type() == QEvent::MouseButtonPress) {
  13. qDebug() << "QEvent::MouseButtonPress:";
  14. o->dumpObjectInfo();
  15. } else if (e->type() == QEvent::MouseButtonRelease) {
  16. qDebug() << "QEvent::MouseButtonRelease:";
  17. o->dumpObjectInfo();
  18. } if (e->type() == QEvent::KeyPress) {
  19. qDebug() << "QEvent::KeyPress:";
  20. o->dumpObjectInfo();
  21. } else if (e->type() == QEvent::KeyRelease) {
  22. qDebug() << "QEvent::KeyRelease:";
  23. o->dumpObjectInfo();
  24. }
  25. return false;
  26. }
  27.  
  28. int main(int argc, char * argv[])
  29. {
  30. QApplication app(argc, argv);
  31. QListWidget * list = new QListWidget();
  32. Test * test = new Test();
  33. addit(list, test);
  34. QListWidgetItem * newItem = new QListWidgetItem("foo 1", list);
  35. newItem->setFlags(Qt::ItemIsEditable);
  36. list->show();
  37. return app.exec();
  38. }
To copy to clipboard, switch view to plain text mode 

Start and double click the 'foo 1' item to begin editing it. Type any key.
The strange thing is that the key releases are caught, but never the key presses.
I tried various things, like looking at the list->itemWidget(item), but that always returns 0 at the places I tried (like after the doubleclick). Where is the keypress handled?

Greetings,
Beluvius