[Interest] Changing key repeat settings in Qt

508 views
Skip to first unread message

Kimmo Viitanen

unread,
Jan 30, 2012, 8:24:34 AM1/30/12
to inte...@qt-project.org
Hi,

Is it possible to change the key repeat settings using Qt? When a
keyboard key is pressed and kept pressed, there is usually a delay
before the key starts repeating. I'd like to reduce this delay.

This is probably not something that is usually desired in an application
(fiddling with user's personal settings), but I'm trying to develop a
game in Qt. In the game, users can move an object with the keyboard.
With the default key delay there is a noticeable pause between the first
movement and subsequent moves.

Documentation didn't turn up anything, so I'm thinking this is not
possible, but it never hurts to ask.

Cheers,

Kimmo
_______________________________________________
Interest mailing list
Inte...@qt-project.org
http://lists.qt-project.org/mailman/listinfo/interest

Konstantin Tokarev

unread,
Jan 30, 2012, 8:35:53 AM1/30/12
to Kimmo Viitanen, inte...@qt-project.org

30.01.2012, 17:24, "Kimmo Viitanen" <kvii...@gmail.com>:


> Hi,
>
> Is it possible to change the key repeat settings using Qt?

No. You should configure underlying OS driver, or filter key events
in your code (e.g., subclass QApplication and redefine notify()).

--
Regards,
Konstantin

Till Oliver Knoll

unread,
Jan 30, 2012, 8:51:35 AM1/30/12
to inte...@qt-project.org

Am 30.01.2012 um 14:24 schrieb Kimmo Viitanen <kvii...@gmail.com>:

> Hi,
>
> ...


> With the default key delay there is a noticeable pause between the first
> movement and subsequent moves.

Hmmm, so you do a single move triggered by a key-press?

IMHO it would be better to detect a key DOWN event instead and keep moving as long as that key is down (or in other words: until you receive a key UP event of the proper key).

Wouldn't that be possible?

Cheers, Oliver

Kimmo Viitanen

unread,
Jan 30, 2012, 10:57:19 AM1/30/12
to inte...@qt-project.org
On 01/30/2012 03:51 PM, Till Oliver Knoll wrote:
> Hmmm, so you do a single move triggered by a key-press?
>
> IMHO it would be better to detect a key DOWN event instead and keep
moving as long as that key is down (or in other words: until you receive
a key UP event of the proper key).
>
> Wouldn't that be possible?
>
> Cheers, Oliver

Thanks!

I didn't originally see an easy way to accomplish this, since the
documentation says that both a keyPressEvent and a keyReleaseEvent are
sent on each auto-repeated press. But now after a quick test, it seems
that isAutoRepeat() is false for the last keyReleaseEvent after a series
of auto-repeated events, so based on this I can detect the physical
press and release.

Cheers,

Kimmo

Reply all
Reply to author
Forward
0 new messages