Results 1 to 5 of 5

Thread: Determining that Caps Lock is on

  1. #1
    Join Date
    Jul 2007
    Location
    California, USA
    Posts
    62
    Thanks
    17
    Thanked 7 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Determining that Caps Lock is on

    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.

  2. #2
    Join Date
    Jan 2006
    Location
    Knivsta, Sweden
    Posts
    153
    Thanks
    30
    Thanked 13 Times in 12 Posts
    Qt products
    Qt4 Qt5
    Platforms
    Unix/X11

    Default Re: Determining that Caps Lock is on

    There is QApplication::keyboardModifiers(), but I think it has the same problem.

  3. #3
    Join Date
    Sep 2009
    Posts
    140
    Thanks
    4
    Thanked 17 Times in 17 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Determining that Caps Lock is on

    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.

  4. #4
    Join Date
    Sep 2009
    Posts
    36
    Thanks
    4
    Thanked 5 Times in 5 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Determining that Caps Lock is on

    I shouldn't try making something up at night -.- {removed useless idea}

  5. #5
    Join Date
    Jul 2007
    Location
    California, USA
    Posts
    62
    Thanks
    17
    Thanked 7 Times in 4 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Determining that Caps Lock is on

    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);

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.