Sorry JD2000, I probably didn't state the problem clearly.

The pushbutton works fine. I just want it clicked when the Enter key is hit.
This is automatic on the default button in a dialog, but not a mainwindow.

Here is what I have tried but it does nothing:

Qt Code:
  1. ui->pbSave->installEventFilter(this);
  2.  
  3. bool MainWindow::eventFilter(QObject *object, QEvent *event)
  4. {
  5. if (object == ui->pbSave && event->type() == QEvent::KeyPress) {
  6. QKeyEvent *keyEvent = static_cast<QKeyEvent *>(event);
  7. if (keyEvent->key() == Qt::Key_Enter) {
  8. ui->pbSave->click();
  9. return true;
  10. } else
  11. return false;
  12. }
  13. return false;
  14. }
To copy to clipboard, switch view to plain text mode 

I am probably not understanding the event filter doc correctly.
Any help appreciated.