PDA

View Full Version : Determining that Caps Lock is on



ntp
30th September 2009, 23:39
Is there a way to determine that Caps Lock is on? It is possible for the caps lock to be on before starting the app so I cannot rely on key events. I had hoped there was a way to query the state of Qt::Key_CapsLock but I don't see one.

For those familiar to wxWidgets, this would be like asking wxGetKeyState on the caps lock key.

drhex
1st October 2009, 09:35
There is QApplication::keyboardModifiers(), but I think it has the same problem.

scascio
1st October 2009, 11:59
It seems you can only detect if the CapsLock is pressed or release in QKeyEvent::key()

But you can always control the text input with QKeyEvent::text() when you need it. if Key_A is pressed, return QString will contain "A" or "a" according to Caps Lock state.

soxs060389
8th October 2009, 01:02
I shouldn't try making something up at night -.- {removed useless idea}

ntp
8th October 2009, 01:08
The good new (for me) is that I need this on windows. The bad news is that the official verdict is that there is no way to do this in qt (if the caps lock was turned on before the app was started).

I am going to have to rely on:

bool capsLogon = (bool)GetAsyncKeyState(VK_CAPITAL);