Results 1 to 3 of 3

Thread: Keypressevent - CTRL Key_Enter

  1. #1
    Join Date
    Jul 2009
    Posts
    20
    Thanks
    1
    Thanked 1 Time in 1 Post

    Default Keypressevent - CTRL Key_Enter

    Hi

    I am using the following code in keypressevent() to catch CTRL+Enter and CTRL+Return keys.

    I find that CTRL+Return works fine, however only the code for ctrl key is passed when i use ctrl+enter(numeric keypad).
    What am i doing wrong here?

    Thanks

    Qt Code:
    1. if ((e->modifiers()==Qt::ControlModifier) && (e->key()==Qt::Key_Return || e->key()==Qt::Key_Enter|| e->key()==Qt::Key_Space) )
    2. {
    3. test;
    4. }
    To copy to clipboard, switch view to plain text mode 

  2. #2
    Join Date
    Mar 2008
    Location
    Kraków, Poland
    Posts
    1,540
    Thanked 284 Times in 279 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Keypressevent - CTRL Key_Enter

    For Enetr from numeric pad You have :
    Qt Code:
    1. e->modifiers()==(Qt::ControlModifier || Qt::KeypadModifier)
    To copy to clipboard, switch view to plain text mode 
    So Yours code must look like :
    Qt Code:
    1. if ((e->modifiers() & Qt::ControlModifier) && (e->key()==Qt::Key_Return || e->key()==Qt::Key_Enter|| e->key()==Qt::Key_Space) )
    2. {
    3. test;
    4. }
    To copy to clipboard, switch view to plain text mode 

  3. #3
    Join Date
    Jul 2009
    Posts
    20
    Thanks
    1
    Thanked 1 Time in 1 Post

    Default Re: Keypressevent - CTRL Key_Enter

    Hi

    Thanks for the reply, but it not work in my case.
    When i debug i find that event->key() returns the key code for CONTROL key and not ENTER.
    event->modifiers() returns the keypadModifier
    Any suggestions?

    Thanks

Similar Threads

  1. Why Ctrl+A not working in QListWidget?
    By rajesh in forum Qt Programming
    Replies: 6
    Last Post: 10th December 2009, 14:40
  2. 'Modifier' key notification (eg. Shift, Ctrl, Alt)
    By squidge in forum Qt Programming
    Replies: 3
    Last Post: 16th November 2009, 16:12
  3. disable ALT+CTRL+DEL!!!!
    By phillip_Qt in forum Qt Programming
    Replies: 10
    Last Post: 3rd November 2009, 09:23
  4. How to catch CTRL+Y in application
    By Morea in forum Qt Programming
    Replies: 1
    Last Post: 29th April 2009, 06:14
  5. CTrl + A
    By navi1084 in forum Qt Programming
    Replies: 1
    Last Post: 23rd October 2008, 09:19

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.