1
我模擬F1鍵使用QTest :: keyPress()方法來測試keypress事件,當我檢查nativeScanCode時F1鍵的模擬,它返回0值。任何人都可以幫忙嗎?QTest :: keyPress沒有返回nativeScanCode
//Code snippet
//To simulate F1 key press
QTest::keyPress(&kboard, Qt::Key_F1);
//To check keypress Event
void keyboard::keyPressEvent(QKeyEvent* ke) {
if (ke->type() == QEvent::KeyPress) {
QKeyEvent* key_event = static_cast<QKeyEvent *>(ke);
//To check F1 key simulation
if (key_event->key() == Qt::Key_F1) {
int nativeCode = key_event->nativeScanCode();
qDebug()<< nativeCode <<endl;
}
}
}
感謝,
VELS