Results 1 to 2 of 2

Thread: QKeyEvent Gives Odd Response to SpaceBar

  1. #1
    Join Date
    Jan 2008
    Posts
    31
    Thanks
    1
    Thanked 2 Times in 2 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default QKeyEvent Gives Odd Response to SpaceBar

    I'm using the following function:

    Qt Code:
    1. void Clone::keyPressEvent( QKeyEvent *event)
    2. {
    3. switch ( kbdItem)
    4. {
    5. case getDriveLetter:
    6. driveLetterProcess( event->text());
    7. break;
    8. case okNotMounted:
    9. notMountedProcess();
    10. break;
    11. case okDeleteFolder:
    12. deleteFolderProcess( event->key());
    13. break;
    14. default:
    15. ;
    16. }
    17. }
    To copy to clipboard, switch view to plain text mode 

    If I press the spacebar, the function ignores the input for the getDriveLetter and okDeleteFolder cases.

    For the okNotMounted case, I ask the user to, "Press any key to continue." If spacebar is selected, rather then entering the notMountedProcess(), the function re-enters the driveLetterProcess( event->text()).

    Works fine for any other key press.


  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    5,372
    Thanks
    28
    Thanked 976 Times in 912 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11 Windows

    Default Re: QKeyEvent Gives Odd Response to SpaceBar

    Spacebar activates the default button. Make sure that the key event doesn't propagate to parent widget.

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.