Results 1 to 3 of 3

Thread: Howto handle key-release with autorepeat key

  1. #1
    Join Date
    Aug 2006
    Posts
    3
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Howto handle key-release with autorepeat key

    Hi all,
    if I press an autorepeat key (like space or a character key) without release the key,
    the keyPressEvent and keyReleaseEvent are emitted continuosly until the key is released. So, how can I handle the "true" release of the key??
    Any suggestion?
    Thanks,
    Marco


    See this example:

    void MyWidget::keyPressEvent(QKeyEvent * event)
    {
    qDebug() << "press";
    ...
    }

    void MyWidget::keyReleaseEvent(QKeyEvent * event)
    {
    qDebug() << "release";
    ...
    }


    <<< I press space key >>>
    output will be:
    press
    release
    press
    release
    press
    release
    ...
    <<< I release the space key >>>
    release

  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: Howto handle key-release with autorepeat key

    Did you try checking QKeyEvent::isAutoRepeat()?

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

    bitChanger (5th September 2007)

  4. #3
    Join Date
    Aug 2006
    Posts
    3
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: Howto handle key-release with autorepeat key

    Thanks this solve my problem!
    I thought that isAutoRepeat() method was for another purpose.
    Bye,
    Marco

    Quote Originally Posted by jacek
    Did you try checking QKeyEvent::isAutoRepeat()?

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.