Hi,
I am simulating F1 key using QTest::keyPress() method to test keypress event, on simulation of F1 key when i check for nativeScanCode, it returns 0 value. can any one help?
//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;
}
}
}
//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;
}
}
}
To copy to clipboard, switch view to plain text mode
Thanks
vels
Bookmarks