Results 1 to 6 of 6

Thread: Question about standard shortcuts

  1. #1
    Join Date
    Sep 2007
    Location
    Vienna, Austria
    Posts
    19
    Thanks
    10
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Windows

    Question Question about standard shortcuts

    My problem is:

    I have a QMainWindow application with many child windows.
    In this application i can open project files which contains many child windows and i have a QAction with which i can close the project(close all child windows). So far so good.
    But when i set the shortcut of this action to CTRL+W i get in trouble with the qt standard shortcuts, where this shortcut is used to close one child window.

    So is there a way of disabling these standard shortcuts?
    Or is the only solution to install a keyeventfilter?

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

    Default Re: Question about standard shortcuts

    Hmm... Qt inherits its accelerators from the desktop it is running on, so it is really Windows or the wm that is responsible. You can catch QShortcutEvent events if you want, but maybe you could just shut the shortcut off or shadow it with your own? Try changing the ShortcutContext of your shortcut to Qt::ApplicationShortcut, maybe it helps.

  3. #3
    Join Date
    Sep 2007
    Location
    Vienna, Austria
    Posts
    19
    Thanks
    10
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Windows

    Default Re: Question about standard shortcuts

    I tried setting the Shortcut context of my QAction to Qt::ApplicationShortcut but it didn't help. pressing ctrl+w is still closing only one mdi window instead of all.

    I noticed that there is this line in my compiler:
    QAction::eventFilter: Ambiguous shortcut overload: Ctrl+W

    In the meanwhile i tried to install a eventfilter in my QMainWindow derivative and to catch the QKeySequence::Close event and to replace it with my own slot.
    but it seems that the standard shortcut is handled before the eventfilter in some way. so the result is that the application first closes the focused mdi child and then triggers the slot?

    btw: yes this problem is only on windows. on mac there isn't such a problem...

    there is also another problem concerning alt+f4:

    i have dockwidgets and toolbars in my application.
    when i undock the toolbars and then press alt+f4 the toolbar is hidden instead of closing the application. the same is with dockwidgets. i tried it in the examples and the result was the same(dockwidgets, mdi, sdi example). is there a property to set?
    Last edited by y.shan; 3rd December 2007 at 14:36.

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

    Default Re: Question about standard shortcuts

    I think you should try to avoid changing the behaviour of standard shortcuts. They are called standard for a reason... Alt+f4 closes the current window and is equal to ctrl+w - take a look at the table in the shortcut docs.

  5. #5
    Join Date
    Sep 2007
    Location
    Vienna, Austria
    Posts
    19
    Thanks
    10
    Qt products
    Qt3 Qt4
    Platforms
    MacOS X Windows

    Default Re: Question about standard shortcuts

    Quote Originally Posted by wysota View Post
    take a look at the table in the shortcut docs.
    you are referring to http://doc.trolltech.com/4.3/qkeysequence.html, are you?

    Actually I'm porting the application from qt3 to qt4 and it would be nice if i can keep the old behaviour of the shortcuts.

    so your suggestion is to use other shortcuts than the standard shortcuts?

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

    Default Re: Question about standard shortcuts

    Yes, that would be best. You can open a message dialog informing users the behaviour has changed first time they start the application.

  7. The following user says thank you to wysota for this useful post:

    y.shan (3rd December 2007)

Similar Threads

  1. QProcess +standard error + windows
    By antonio.r.tome in forum Qt Programming
    Replies: 0
    Last Post: 18th April 2006, 15:58

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.