Results 1 to 8 of 8

Thread: keyPressEvent - "ctrl + tab" handle two time

  1. #1
    Join Date
    May 2010
    Posts
    39
    Thanks
    11
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4

    Default keyPressEvent - "ctrl + tab" handle two time

    code Code:
    1. bool Widget::eventFilter(QObject *target, QEvent *event)
    2. {
    3. QKeyEvent *keyEvent = static_cast<QKeyEvent*>(event);
    4. if (keyEvent->modifiers() == Qt::ControlModifier) {
    5. if (keyEvent->key() == Qt::Key_Tab) {
    6. qDebug() << "Handling..";
    7. return true;
    8. }
    9. return false;
    10. }
    11. }
    To copy to clipboard, switch view to plain text mode 


    then I see that this handler called two time:

    ApplicationOutput:
    Handling..
    Handling..
    Last edited by somename; 30th May 2010 at 18:34.

  2. #2
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: keyPressEvent - "ctrl + tab" handle two time

    did you hold the button, then see autoRepeatDelay, autoRepeatInterval.

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

    somename (30th May 2010)

  4. #3
    Join Date
    May 2010
    Posts
    39
    Thanks
    11
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4

    Default Re: keyPressEvent - "ctrl + tab" handle two time

    No, I have no button
    Last edited by somename; 30th May 2010 at 19:04.

  5. #4
    Join Date
    Jan 2006
    Location
    Belgium
    Posts
    1,938
    Thanked 268 Times in 268 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows
    Wiki edits
    20

    Default Re: keyPressEvent - "ctrl + tab" handle two time

    Quote Originally Posted by somename View Post
    No, I have no button
    The ctrl and tab button (key)

  6. The following user says thank you to tbscope for this useful post:

    somename (30th May 2010)

  7. #5
    Join Date
    Apr 2010
    Posts
    769
    Thanks
    1
    Thanked 94 Times in 86 Posts
    Qt products
    Qt3 Qt4
    Platforms
    Unix/X11

    Default Re: keyPressEvent - "ctrl + tab" handle two time

    KeyEvent records any sort of key event - both key press and key release. You're probably seeing the initial press followed by the subsequent release being processed here.

    Check the Type of the event to see if it is KeyPress or KeyRelease, and only handle one of them.

  8. The following user says thank you to SixDegrees for this useful post:

    somename (30th May 2010)

  9. #6
    Join Date
    May 2010
    Posts
    39
    Thanks
    11
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4

    Default Re: keyPressEvent - "ctrl + tab" handle two time

    Thanks! I have forgotten this!

  10. #7
    Join Date
    May 2010
    Posts
    39
    Thanks
    11
    Thanked 1 Time in 1 Post
    Qt products
    Qt3 Qt4

    Default Re: keyPressEvent - "ctrl + tab" handle two time

    and..
    How to use auto repeat delay?

  11. #8
    Join Date
    Jan 2006
    Location
    Germany
    Posts
    4,380
    Thanks
    19
    Thanked 1,005 Times in 913 Posts
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows Symbian S60
    Wiki edits
    5

    Default Re: keyPressEvent - "ctrl + tab" handle two time

    I never have dealt with such kind, but I would start with: QShortcut::autoRepeat.

Similar Threads

  1. Shortcut: CTRL + SHIFT + "letters"
    By smarinr in forum Qt Programming
    Replies: 17
    Last Post: 22nd May 2009, 09:34
  2. Replies: 3
    Last Post: 8th July 2008, 19:37
  3. QTreeWidget and keep "focus drawing" every time
    By Lykurg in forum Qt Programming
    Replies: 0
    Last Post: 3rd April 2008, 17:04
  4. Translation QFileDialog standart buttons ("Open"/"Save"/"Cancel")
    By victor.yacovlev in forum Qt Programming
    Replies: 4
    Last Post: 24th January 2008, 19:05

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.