Results 1 to 6 of 6

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

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    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.