My Qt GUI application has a main dialog, and I want all key event to be processed in the dialog but not its children widgets (event they get focus), so I install a event filter for qApp in main():

QApplication app(argc, 0);
MyDialog * pDlg = new MyDialog(0, Qt::WindowTitleHint | Qt::CustomizeWindowHint);
qApp->installEventFilter(pDlg);

Then in MyDialog.cpp:

bool MyDialog::eventFilter(QObject * watched, QEvent * event)
{
if (watched == qApp)
{
if (event->type() == QEvent::KeyPress)
{
// do something
return true; // break point 1
}
return false; // break point 2
}
return QDialog::eventFilter(watched, event);
}

I set 2 breakpoints. During debugging, the breakpoint 2 can be reached, it means that qApp dispatch events to dialog's eventfilter. But breakpoint 1 never been reached when I press any key. Why the QKeyevent not handled in qApp ?