[Qt-interest] Standard keys in menus
KC Jones
kc at asperasoft.com
Sun Oct 18 19:54:15 CEST 2009
First post here, pardon me if this is a well known issue. I searched
the archives and poured over the docs to no avail, yet I can't believe
I'm the first person to run into this...
Is there a standard way to handle standard key actions in menus?
I'm building my application menu and I need to add items for various
standard keys. My app does not implement any custom actions for these
keys and relies happily on Qt to implement the functionality on a per
widget basis. Let's consider the delete action (just because its
shortcut key display is non-trivial, Cut, Copy, Paste are also
relevant here).
I see the standard key definition, QKeySequence::Delete
I add it to my edit menu by creating a delete action with the shortcut
set to QKeySequence::Delete and the shortcut shows correctly. Nice.
When I hit the DEL key itself, it works as expected.
So far so good.
But if I select the menu item nothing happens since I have not defined
that slot.
And when focus is on some widget that does not support delete, the
menu item is not disabled.
Am I really supposed to code slots for each standard key I put in the menu?
And how am I supposed to implement correct menu enable/disable sensitivity?
Why is the Menus example so lame in this regard? It "implements" a
'Cut' menu item that does nothing but update a status bar.
Unless I'm missing something, I would suggest it would be very useful
to provide static QAction instances for many of the statdard
QKeySequences.
More information about the Qt-interest-old
mailing list