Results 1 to 4 of 4

Thread: Want to detect keyboard key press other than modifier keys

  1. #1
    Join Date
    Apr 2012
    Location
    India.
    Posts
    88
    Thanked 8 Times in 8 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Want to detect keyboard key press other than modifier keys

    Hi All,
    I have Qt application in which I want to handle combination of "SHIFT + B" & button press on QPushButton. (Shortcut is combination of "SHIFT + B + button press)
    I am able to identify ctrl key press using QApplication::keyboardModifiers() in button press handler, but I am not able to find a way to detect whether "B" is currently pressed or not, if anyone have some idea, please help.

    I don't want to use keypress & keyrelease to track the keyboard key.

    Thanks.

  2. #2
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,391
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Want to detect keyboard key press other than modifier keys

    I don't want to use keypress & keyrelease to track the keyboard key.
    Can you explain why not ?

  3. #3
    Join Date
    Apr 2012
    Location
    India.
    Posts
    88
    Thanked 8 Times in 8 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Want to detect keyboard key press other than modifier keys

    Hi,
    The reason I don't want to use keypress & keyrelease is, I was searching something similar to queryKeyboardModifiers which is I think supported in Qt 5.1, otherwise as a last option I will use keypress & keyrelease event.
    One more option I was thinking is if it's not possible in Qt then I will use platform specific API for detecting this key.
    for your information, I am using Qt 4.7.3.

    Thanks,

  4. #4
    Join Date
    Sep 2009
    Location
    Wroclaw, Poland
    Posts
    1,391
    Thanked 342 Times in 324 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows Android

    Default Re: Want to detect keyboard key press other than modifier keys

    So, you will give away platform portability and/or compatibility between Qt versions just to solve such simple task in platform-specific way ? Anyway, its your decision, but I'd go for keypress / keyrelease, it will work in Qt4/Qt5 and all platforms.
    For windows, you can use GetKeyState function. I don't know about mac or unix.

Similar Threads

  1. Control buttons with keyboard keys
    By Robobulls in forum Newbie
    Replies: 3
    Last Post: 11th June 2013, 22:55
  2. Replies: 3
    Last Post: 11th December 2012, 20:48
  3. Replies: 5
    Last Post: 17th June 2011, 09:43
  4. Detect Arrow Keys
    By Ebonair in forum Qt Programming
    Replies: 4
    Last Post: 1st October 2010, 03:55
  5. how to Simulate the keyboard press
    By duduqq in forum Qt Programming
    Replies: 3
    Last Post: 9th August 2008, 16:50

Tags for this Thread

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.