我需要在 Qt 中模拟“Enter”键事件。我怎样才能做到这一点?
最佳答案
正确答案可能是这样的:
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)
关于qt - 如何在 Qt 中模拟用户交互(按键事件)?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2035310/