Results 1 to 8 of 8

Thread: QTest::keyPress is not returning nativeScanCode

  1. #1
    Join Date
    Apr 2010
    Posts
    16
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default QTest::keyPress is not returning nativeScanCode

    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?

    Qt Code:
    1. //To simulate F1 key press
    2. QTest::keyPress(&kboard, Qt::Key_F1);
    3.  
    4. //To check keypress Event
    5. void keyboard::keyPressEvent(QKeyEvent* ke) {
    6. if ( ke->type() == QEvent::KeyPress ) {
    7. QKeyEvent* key_event = static_cast<QKeyEvent *>(ke);
    8. //To check F1 key simulation
    9. if (key_event->key() == Qt::Key_F1) {
    10. int nativeCode = key_event->nativeScanCode();
    11. qDebug()<< nativeCode <<endl;
    12. }
    13. }
    14. }
    To copy to clipboard, switch view to plain text mode 

    Thanks
    vels

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QTest::keyPress is not returning nativeScanCode

    You are using artificial events so there is no extended information available for it.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  3. The following user says thank you to wysota for this useful post:

    vels (10th May 2010)

  4. #3
    Join Date
    Apr 2010
    Posts
    16
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QTest::keyPress is not returning nativeScanCode

    Hi,

    what is an extended information, is nativeScancode an extended info? plz throw some light on it.

    Thanks
    vels

  5. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QTest::keyPress is not returning nativeScanCode

    If you don't know what nativeScancode is, why do you use it?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  6. #5
    Join Date
    Apr 2010
    Posts
    16
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QTest::keyPress is not returning nativeScanCode

    I pretty well know nativeScancode is a unique unsigned int value which is returned on occurrence of a key stroke; from your POV artificial events (QTest::keyPress) don’t give extended information, want to know is nativeScancode one such extended information?

  7. #6
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QTest::keyPress is not returning nativeScanCode

    Would I write my post like that if it weren't? I assumed you have read the documentation prior to writing your post, maybe I assumed wrong, so - yes, according to what the docs say, native scan code is an extended information provided by the platform. Are you sure you do need this kind of information?
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


  8. #7
    Join Date
    Apr 2010
    Posts
    16
    Thanks
    5
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: QTest::keyPress is not returning nativeScanCode

    yep, I will ignore nativeScanCode and make use of QKeyEvent::key() which returns unicode

  9. #8
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,359
    Thanks
    3
    Thanked 5,015 Times in 4,792 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: QTest::keyPress is not returning nativeScanCode

    QKeyEvent::key() doesn't return unicode. It returns enum values.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Qtest
    By gollaan in forum Qt Programming
    Replies: 1
    Last Post: 17th December 2008, 09:04
  2. fn+f1 keypress detect
    By oguzy in forum Qt Programming
    Replies: 1
    Last Post: 16th November 2008, 16:21
  3. keypress event
    By vishesh in forum Qt Programming
    Replies: 2
    Last Post: 3rd November 2007, 14:12
  4. QTest
    By LMZ in forum Qt Programming
    Replies: 5
    Last Post: 1st June 2007, 08:34
  5. QTest
    By Mordicus in forum Qt Programming
    Replies: 1
    Last Post: 25th July 2006, 10:35

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.