PDA

View Full Version : QKeySequence with Qt::Key_CapsLock



budda
19th August 2014, 19:47
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

new QShortcut(QKeySequence(Qt::SHIFT + Qt::Key_A), this, SLOT(mySlotFor_A() ) );

d_stranz
19th August 2014, 23:28
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.

budda
20th August 2014, 03:23
new QShortcut(QKeySequence(Qt::Key_CapsLock + Qt::Key_A), this, SLOT(mySlotFor_CapA()));
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....

d_stranz
20th August 2014, 04:44
Why don't you try Qt::SHIFT instead of Qt::Key_CapsLock?

budda
20th August 2014, 06:55
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...

d_stranz
20th August 2014, 18:45
So did you try the experiment? If you have caps lock on, does the SHIFT + A key sequence work?

budda
20th August 2014, 20:06
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