Simulate a Key event press/release in QT 4

Qt Send Event Keypress

QApplication::sendEvent(this, new QKeyEvent
      (QEvent::KeyPress, Qt::Key_Dead_Diaeresis, Qt::NoModifier, QString("¨")));
 
//Another way I guess easy to understand :) 
//Although both are same
QKeyEvent keyEvent(QEvent::KeyPress,Qt::Key_Escape, Qt::NoModifier);
QApplication::sendEvent(this, &keyEvent);

Popularity: 52% [?]

Share and Enjoy:
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google Bookmarks

Leave a Reply