QTest::keyPress is not returning nativeScanCode

Posted by vels on Stack Overflow See other posts from Stack Overflow or by vels
Published on 2010-05-10T08:29:05Z Indexed on 2010/05/10 8:34 UTC
Read the original article Hit count: 357

Filed under:
|
|

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?

//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;
}
  }
}

Thanks,

vels

© Stack Overflow or respective owner

Related posts about qt4

Related posts about qttest