I've used the same system: sending a signal when a key has been pressed.

I need to capitalise all the user inputs but not what the gui automatically inserts, so a signal is much more efficient than a validator.

And it's 10 lines

Qt Code:
  1. protected:
  2. void keyPressEvent(QKeyEvent* e)
  3. {
  4. if (e->key() >= Qt::Key_A && e->key() <= Qt::Key_Z)
  5. emit KeyPressed(e->text().toUpper().at(0));
  6. else
  7. QLineEdit::keyPressEvent(e);
  8. }
  9. signals:
  10. void KeyPressed(const QChar&);
To copy to clipboard, switch view to plain text mode