Results 1 to 6 of 6

Thread: Keyboard combination of ctrl+shift+alt not supported?

  1. #1
    Join Date
    Mar 2010
    Posts
    3
    Platforms
    Unix/X11

    Default Keyboard combination of ctrl+shift+alt not supported?

    I'm running PC-BSD 8.0 operating system at work which use KDE 4.3.5 and thus Qt.

    I have an application (developed in java, but not Qt related) that requires me to press-hold ctrl+shift+alt in certain situations and then the click the right mouse button. But it doesn't work. I tried to see if the combination worked in "global keyboard shortcuts" in the system settings of KDE. When I try to set a custom combination for any of the action and press these three modifier keys at the same time I get (instantaneously) a popup warning window saying:
    "The key you just pressed is not supported by Qt."
    Is that true? That is is impossible to get it to work (short of implementing it in the Qt toolkit if it really is not supported)?
    If it is supported but Qt in general, anyone have an idea where I should start digging, perhaps PC-BSD <--> KDE issue?

    I have a few colleagues thinking I should run Gnome (and thus GTK+, they use Ubuntu Linux)... Can anyone save me?

  2. #2
    Join Date
    Jan 2009
    Location
    The Netherlands and Spain
    Posts
    150
    Thanks
    6
    Thanked 18 Times in 18 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Keyboard combination of ctrl+shift+alt not supported?

    The combination of Ctrl+Shift+Alt can't be used as a keyboard shortcut, because all three are Keyboard Modifiers which must be followed by a "normal" key. Hence Ctrl+Shift+Alt+"A" would be a valid combination.
    If your program handles mouse events correctly, it should check the state of these Keyboard Modifiers at every mouse event and accept Ctrl+Shift+Alt as a valid combination.

  3. #3
    Join Date
    Mar 2010
    Posts
    3
    Platforms
    Unix/X11

    Default Re: Keyboard combination of ctrl+shift+alt not supported?

    Yes the application handles it correctly (when the mouse event is fired it checks that the right mouse button is clicked and all three modifier keys). It works on windows and linux with gnome(GTK+).
    The question was if KDE's error message blaming Qt was correct or not. The global keyboard shortcut setup doesn't even allow me to press e.g. ctrl+shift+alt+A, when I hold down the three modifier keys the error message is shown and the assignment of a shortcut is blocked.

    I would assume any good toolkit for handling keyboard input supports all three (alt, shift, ctrl) modifiers keys at the same time. Perhaps I should blame Freebsd in some way, perhaps the combination of these keys is propagated up to Qt as some other strange key combination, not what Qt would expect from ctrl+shift+alt being pressed.

  4. #4
    Join Date
    Jan 2009
    Location
    The Netherlands and Spain
    Posts
    150
    Thanks
    6
    Thanked 18 Times in 18 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11

    Default Re: Keyboard combination of ctrl+shift+alt not supported?

    That must be a new "feature" of KDE 4.3.5, because I'm using KDE 3.5 and I can make a ctrl+shift+alt+A shortcut without any problem.
    Maybe it's better to ask this question to a specific KDE-forum?


    I just tested a few shortcuts in my own program (using Qt 4.6.0) and a few strange things came out:
    shift + alt + A = OK
    shift + ctrl + A = OK
    alt + ctrl + A = NOT OK
    but:
    alt + ctrl + B = OK huh?
    shift + ctrl + alt + A = OK!!!
    The last one proofs that Qt has no problem with shift+ctrl+alt.

    All tested like this:
    Qt Code:
    1. testAction = new QAction(this);
    2. testAction->setShortcut(Qt::SHIFT | Qt::CTRL | Qt::ALT | Qt::Key_A);
    3. this->addAction(testAction);
    4. connect(testAction, SIGNAL(triggered()), this, SLOT(textChanged()));
    To copy to clipboard, switch view to plain text mode 
    I'll leave this problem to people who know more about it...
    Sorry I couldn't help you.

  5. #5
    Join Date
    Oct 2009
    Posts
    151
    Thanks
    6
    Thanked 13 Times in 11 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Keyboard combination of ctrl+shift+alt not supported?

    You may want to have a play with the QKeyEvent class, this lets you examine the keycodes directly.

  6. #6
    Join Date
    Mar 2010
    Posts
    3
    Platforms
    Unix/X11

    Default Re: Keyboard combination of ctrl+shift+alt not supported?

    Ok I managed to slam together a little program reading the QKeyEvent, my first venture into Qt.

    I discovered that the problem is not control+shift+alt, but in fact the shorter alt+shift (or shift+alt).
    The strange thing is that QKeyEvent::key() returns 0xffffffff, which is not listed as anyone on the enum Qt::Key page.
    KDE probably complains when it got this 0xffffffff and says Qt doesn't support it.

    But the native*() functions doesn't return any value that is too strange, but perhaps they are. Can anyone download and compile program included and try the same thing and post the output? Would be grateful, because if they differ in the native codes (shift+alt/alt+shift) I have to start digging down into FreeBSD lower levels and see what is cause.

    Edit: Forgot to mention. I have a Swedish keyboard. In the regional settings I tested changing layout to US keyboard layout. The only difference is the nativeModifier that gets its value "prefixed" with 0x20 (without the 0x, but it's hexadecimal).
    I don't have any real English keyboard to try with.
    Edit 2: Couldn't attach a file, changed the source code dialog to include the whole program.


    Here is the code of the interesting function and then some output (with comments I made to clarify).

    Qt Code:
    1. #include <QApplication>
    2. #include <QWidget>
    3. #include <QKeyEvent>
    4. #include <stdio.h>
    5.  
    6. class SenseKey : public QWidget
    7. {
    8. public:
    9. SenseKey (QWidget *parent, Qt::WindowFlags);
    10.  
    11. protected:
    12. void keyPressEvent (QKeyEvent *);
    13. };
    14.  
    15.  
    16.  
    17. SenseKey::SenseKey (QWidget *parent, Qt::WindowFlags flags) :
    18. QWidget (parent, flags) {}
    19.  
    20. void SenseKey::keyPressEvent (QKeyEvent *qke)
    21. {
    22. qke->accept();
    23. switch (qke->key())
    24. {
    25. case Qt::Key_B:
    26. printf("----------------------------------------------------------------------------------------\n");
    27. return;
    28. case Qt::Key_unknown:
    29. printf("Unkown key\n");
    30. return;
    31. case Qt::Key_Shift:
    32. printf("key(): Shift\t");
    33. break;
    34. case Qt::Key_Control:
    35. printf("key(): Control\t");
    36. break;
    37. case Qt::Key_Alt:
    38. printf("key(): Alt\t");
    39. break;
    40. default:
    41. printf("key(): %x\t", qke->key());
    42. }
    43. printf("nativeModifiers(): %x\t", qke->nativeModifiers());
    44. printf("nativeScanCode(): %x\t", qke->nativeScanCode());
    45. printf("nativeVirtualKey(): %x\n", qke->nativeVirtualKey());
    46. return;
    47. }
    48.  
    49.  
    50. int main(int argc, char *argv[])
    51. {
    52. QApplication app(argc, argv);
    53.  
    54. SenseKey *sens = new SenseKey(0, 0);
    55.  
    56. //app.setMainWidget (sens);
    57.  
    58. sens->show();
    59. return app.exec();
    60. }
    To copy to clipboard, switch view to plain text mode 

    To differentiate better I press the 'b' key between each attempt so you others can see which keys were triggered in each combined stroke.

    Qt Code:
    1. key(): Control nativeModifiers(): 10 nativeScanCode(): 25 nativeVirtualKey(): ffe3
    2. ----------------------------------------------------------------------------------------
    3. key(): Shift nativeModifiers(): 10 nativeScanCode(): 32 nativeVirtualKey(): ffe1
    4. ----------------------------------------------------------------------------------------
    5. key(): Alt nativeModifiers(): 10 nativeScanCode(): 40 nativeVirtualKey(): ffe9
    6. ----------------------------------------------------------------------------------------
    7. // Press-and-hold Control and press Shift
    8. key(): Control nativeModifiers(): 10 nativeScanCode(): 25 nativeVirtualKey(): ffe3
    9. key(): Shift nativeModifiers(): 14 nativeScanCode(): 32 nativeVirtualKey(): ffe1
    10. ----------------------------------------------------------------------------------------
    11. // Press-and-hold Alt and press Control
    12. key(): Alt nativeModifiers(): 10 nativeScanCode(): 40 nativeVirtualKey(): ffe9
    13. key(): Control nativeModifiers(): 18 nativeScanCode(): 25 nativeVirtualKey(): ffe3
    14. ----------------------------------------------------------------------------------------
    15. // Press-and-hold Shift and press Alt
    16. key(): Shift nativeModifiers(): 10 nativeScanCode(): 32 nativeVirtualKey(): ffe1
    17. key(): ffffffff nativeModifiers(): 11 nativeScanCode(): 40 nativeVirtualKey(): fe0a
    18. ----------------------------------------------------------------------------------------
    19. // Press-and-hold Alt and press Shift
    20. key(): Alt nativeModifiers(): 10 nativeScanCode(): 40 nativeVirtualKey(): ffe9
    21. key(): ffffffff nativeModifiers(): 18 nativeScanCode(): 32 nativeVirtualKey(): fe0a
    22. ----------------------------------------------------------------------------------------
    23. // Press-and-hold Control, press-and-hold Shift and press Alt
    24. key(): Control nativeModifiers(): 10 nativeScanCode(): 25 nativeVirtualKey(): ffe3
    25. key(): Shift nativeModifiers(): 14 nativeScanCode(): 32 nativeVirtualKey(): ffe1
    26. key(): ffffffff nativeModifiers(): 15 nativeScanCode(): 40 nativeVirtualKey(): fe0a
    27. ----------------------------------------------------------------------------------------
    28. // Press-and-hold Control, press-and-hold Alt and press Shift
    29. key(): Control nativeModifiers(): 10 nativeScanCode(): 25 nativeVirtualKey(): ffe3
    30. key(): Alt nativeModifiers(): 14 nativeScanCode(): 40 nativeVirtualKey(): ffe9
    31. key(): ffffffff nativeModifiers(): 1c nativeScanCode(): 32 nativeVirtualKey(): fe0a
    32. ----------------------------------------------------------------------------------------
    To copy to clipboard, switch view to plain text mode 
    Last edited by christer; 10th March 2010 at 16:19.

Similar Threads

  1. Minor bug in QMdiArea/QSubMdiWindow: Ctrl+Shift+Tab
    By epsilon in forum Qt Programming
    Replies: 0
    Last Post: 3rd March 2010, 06:23
  2. 'Modifier' key notification (eg. Shift, Ctrl, Alt)
    By squidge in forum Qt Programming
    Replies: 3
    Last Post: 16th November 2009, 16:12
  3. Shortcut: CTRL + SHIFT + "letters"
    By smarinr in forum Qt Programming
    Replies: 17
    Last Post: 22nd May 2009, 09:34
  4. how to disable Alt F4 combination
    By omprakash in forum Qt Programming
    Replies: 3
    Last Post: 17th August 2008, 20:18
  5. Replies: 1
    Last Post: 8th March 2007, 10:12

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.