Results 1 to 7 of 7

Thread: QKeySequence with Qt::Key_CapsLock

  1. #1
    Join Date
    Mar 2010
    Posts
    86
    Thanks
    11
    Thanked 7 Times in 4 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default QKeySequence with Qt::Key_CapsLock

    is it possible to include in a QKeySequence Qt::Key_CapsLock or is the state of a capslock always determined in an EventFilter method function with QEvent::KeyPress?
    I'm just wondering if I can create QShortcut's that include capslock...... as I have for example
    Qt Code:
    1. new QShortcut(QKeySequence(Qt::SHIFT + Qt::Key_A), this, SLOT(mySlotFor_A() ) );
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QKeySequence with Qt::Key_CapsLock

    I would think that having caps lock pressed would result in the Shift modifier being sent as part of the key event, so the answer is probably "yes". This should be dead simple to test - write the key sequence as you have suggested above, do not turn on caps lock or press shift, then press the letter "a". Do the same with caps lock pressed. If your shortcut is activated in the second case but not the first, then you know.

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

    budda (20th August 2014)

  4. #3
    Join Date
    Mar 2010
    Posts
    86
    Thanks
    11
    Thanked 7 Times in 4 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QKeySequence with Qt::Key_CapsLock

    Qt Code:
    1. new QShortcut(QKeySequence(Qt::Key_CapsLock + Qt::Key_A), this, SLOT(mySlotFor_CapA()));
    To copy to clipboard, switch view to plain text mode 
    it stays lower case.....
    guess Qt::Key_CapsLock is a bool state & not a valid part of a QKeySequence...
    makes sense because capslock isn't really a combination key event,
    guess I'll have to do it all in the EventFilter method and not use QShortcuts....

  5. #4
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QKeySequence with Qt::Key_CapsLock

    Why don't you try Qt::SHIFT instead of Qt::Key_CapsLock?

  6. #5
    Join Date
    Mar 2010
    Posts
    86
    Thanks
    11
    Thanked 7 Times in 4 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QKeySequence with Qt::Key_CapsLock

    I do have the QKeySequence(Qt::SHIFT + Qt::Key_A) ... I was just trying to be thorough and have the capsLock in there as well...

  7. #6
    Join Date
    Jan 2008
    Location
    Alameda, CA, USA
    Posts
    5,230
    Thanks
    302
    Thanked 864 Times in 851 Posts
    Qt products
    Qt5
    Platforms
    Windows

    Default Re: QKeySequence with Qt::Key_CapsLock

    So did you try the experiment? If you have caps lock on, does the SHIFT + A key sequence work?

  8. #7
    Join Date
    Mar 2010
    Posts
    86
    Thanks
    11
    Thanked 7 Times in 4 Posts
    Qt products
    Qt4 Qt5
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: QKeySequence with Qt::Key_CapsLock

    the SHIFT + A produces a capital A with CapsLock on OR off. I think CapsLock is just a boolean state that you have to implement yourself in the EventFilter, it has no bearing on QKeySequences

  9. The following user says thank you to budda for this useful post:

    d_stranz (21st August 2014)

Similar Threads

  1. Qt5 and QKeySequence new behavior
    By roxton in forum Qt Programming
    Replies: 0
    Last Post: 10th June 2013, 10:39
  2. Issues with QKeySequence when porting to Qt5
    By fedcer in forum Qt Programming
    Replies: 0
    Last Post: 3rd April 2013, 15:05
  3. QKeySequence not working in OSX 10.6? (Qt4.6.0beta1)
    By draculr in forum Qt Programming
    Replies: 0
    Last Post: 17th October 2009, 07:49
  4. QKeySequence widget?
    By ralsina in forum Qt Programming
    Replies: 1
    Last Post: 27th February 2009, 10:02
  5. QKeySequence - get each QKey
    By thomaspu in forum Qt Programming
    Replies: 4
    Last Post: 17th July 2008, 15:30

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.