#include class MyWidget : public QLineEdit { public: MyWidget (QWidget* parent =0) : QLineEdit (parent) {} protected: void keyPressEvent (QKeyEvent* k) { QString text; if ( k->modifiers() &Qt::ControlModifier ) text.append ("Ctrl "); if ( k->modifiers() &Qt::ShiftModifier ) text.append ("Shift "); if ( k->modifiers() &Qt::AltModifier ) text.append ("Alt "); if ( k->key() < 0x100 ) text.append (QChar (k->key())); text.append (QString (" (0x%1)").arg (k->key(), 0, 16)); setText (text); } }; int main (int argc, char* argv[]) { QApplication a (argc, argv); MyWidget w; w.show(); return a.exec(); }