Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I simulate user interaction (key press event) in Qt?

Tags:

keyevent

qt

qt4

I need to simulate "Enter" key event in Qt. How can I do this?

like image 972
Andersson83 Avatar asked Jan 09 '10 23:01

Andersson83


1 Answers

The correct answer might be this:

QKeyEvent *event = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Enter, Qt::NoModifier); QCoreApplication::postEvent (receiver, event); 

in fact there are no matching function for call to

QtKeyEvent::QtKeyEvent(Type type, int key)

but there is:

QtKeyEvent::QtKeyEvent(Type type, int key, Qt::KeyboardModifiers modifiers)

like image 115
dnlcrl Avatar answered Sep 22 '22 13:09

dnlcrl