Results 1 to 2 of 2

Thread: Detect shift/cntrl/alt without event

  1. #1
    Join Date
    Jul 2012
    Posts
    248
    Thanks
    29
    Thanked 15 Times in 14 Posts
    Qt products
    Qt4
    Platforms
    Windows

    Default Detect shift/cntrl/alt without event

    WHat's the right way to detect whether the modifier-keys are currently down or not?

    I am implementing a custom scroll area, and how i scroll changes depending on whether these keys are up or down.

    For scrolling, i connect to the actionTriggered(int) signal of the scrollbar and adjust its position accordingly.
    But that way i do not get passed a Q*Event, and thus no modifiers() to check.


    Monitoring key events doesnt seem to be an option.


    thanks.

  2. #2
    Join Date
    Mar 2011
    Location
    Hyderabad, India
    Posts
    1,882
    Thanks
    3
    Thanked 452 Times in 435 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows
    Wiki edits
    15

    Default Re: Detect shift/cntrl/alt without event

    Use QApplication::keyboardModifiers()
    When you know how to do it then you may do it wrong.
    When you don't know how to do it then it is not that you may do it wrong but you may not do it right.

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

    tuli (3rd May 2013)

Similar Threads

  1. Detect click event in QPlainTextEdit
    By qt_developer in forum Qt Programming
    Replies: 2
    Last Post: 27th June 2013, 15:10
  2. Key Press Event and Shift key problem
    By Teefs in forum Qt Programming
    Replies: 7
    Last Post: 18th April 2011, 09:39
  3. how to shift the focus to enter
    By gu574vo in forum Qt Programming
    Replies: 2
    Last Post: 27th October 2010, 22:45
  4. shift + key
    By jajdoo in forum Newbie
    Replies: 5
    Last Post: 22nd July 2010, 18:25
  5. QPen color shift
    By Alberto in forum Qt Programming
    Replies: 0
    Last Post: 22nd October 2008, 11:35

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
  •  
Qt is a trademark of The Qt Company.