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?
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.
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?
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.
Re: Question about standard shortcuts
Quote:
Originally Posted by
wysota
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?
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.