I need to simulate "Enter" key event in Qt. How can I do this?
问问题
25815 次
2 回答
27
正确的答案可能是这样的:
QKeyEvent *event = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Enter, Qt::NoModifier);
QCoreApplication::postEvent (receiver, event);
实际上没有匹配的函数来调用
QtKeyEvent::QtKeyEvent(Type type, int key)
但是还有:
QtKeyEvent::QtKeyEvent(Type type, int key, Qt::KeyboardModifiers modifiers)
于 2012-01-23T15:10:28.410 回答
23
QKeyEvent *event = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Enter);
QCoreApplication::postEvent (receiver, event)
于 2010-01-10T00:26:42.820 回答