Results 1 to 5 of 5

Thread: Keyboard shortcuts problem.

  1. #1
    Join Date
    Apr 2006
    Location
    Minsk, Belarus
    Posts
    23
    Thanks
    3
    Thanked 4 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Keyboard shortcuts problem.

    I have an action in the main menu of my application with keyboard shortuct set to "Del". It works fine, and pressing Del correctly triggers the action.

    The problem is that I have one single widget in my app which should handle the "Del" press differently (actually this is a file brower, and pressing del there should delete selected files instead of performing main delete functionality of the app). Overloading the keyPressEvent for this browser and handling the del key press there doesn't give the desired result - in most cases the action is triggered, that is not right.

    The deisred effect is that del pressed in the browser deletes files, and del pressed anywhere else fires the action. Btw, such behavior is shown by the textboxes, pressing del in the textbox correctly deletes the symbol under cursor instead of fiting the action.

    As far as I understand, this should be somehow resolved by using event filters, but I'm not that proficient with them. Can someone help me out?

    BTW, changing the action shortcut is not an option.

    Thank you.

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,012 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Keyboard shortcuts problem.

    Try disabling the action when it is not valid.

  3. #3
    Join Date
    Apr 2006
    Location
    Minsk, Belarus
    Posts
    23
    Thanks
    3
    Thanked 4 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Keyboard shortcuts problem.

    This does not help too much. Action still receives the event but doesn't trigger itself.

  4. #4
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,364
    Thanks
    3
    Thanked 5,012 Times in 4,791 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Wiki edits
    10

    Default Re: Keyboard shortcuts problem.

    You can try to change the scope of one of those actions (or both) using QAction::setShortcutContext().

  5. #5
    Join Date
    Apr 2006
    Location
    Minsk, Belarus
    Posts
    23
    Thanks
    3
    Thanked 4 Times in 3 Posts
    Qt products
    Qt4
    Platforms
    MacOS X Windows

    Default Re: Keyboard shortcuts problem.

    Looks like I have found the solution for this problem: handling ShortcutOverride event instead of KeyPress event solves the case.

    Anyway, thanks for your help.

Similar Threads

  1. Discussion about developing an onscreen keyboard in Qt
    By montylee in forum Qt Programming
    Replies: 6
    Last Post: 2nd January 2009, 20:09
  2. Weird problem: multithread QT app kills my linux
    By Ishark in forum Qt Programming
    Replies: 2
    Last Post: 8th August 2008, 09:12
  3. Steps in solving a programming problem?
    By triperzonak in forum General Programming
    Replies: 8
    Last Post: 5th August 2008, 08:47
  4. On Screen Keyboard Problem
    By cutie.monkey in forum Qt Programming
    Replies: 1
    Last Post: 16th July 2008, 13:28
  5. Replies: 5
    Last Post: 23rd February 2007, 10:23

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.