我需要在Qt中模拟"输入"键事件.我怎样才能做到这一点?
QKeyEvent *event = new QKeyEvent ( QEvent::KeyPress, Qt::Key_Enter); QCoreApplication::postEvent (receiver, event)
正确答案可能是这样的:
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)