How do I check shortcuts for duplicates in a Qt app?

Viewed 601

I want to allow my users assign their own shortcuts for various operations. Qt offers a standard widget for this purpose, QKeySequenceEdit. Unfortunately, this widget does not check its input for duplicates and happily accepts even the standard combinations like Ctrl+C etc. What I'd like to do is:

  • Ideally, get a list of all shortcuts active in my application along with their translation hints. I don't think it's possible.
  • Less ideally, connect to QKeySequenceEdit::editingFinished(), create a shortcut and trigger it somehow to watch for the QShortcut::activatedAmbiguously() signal. However, there seems to be no way to trigger a shortcut programmatically.

Could of course resort to feeding the key sequence to the OS and get it played back to check for ambiguous activation, but it looks rather far-fetched. Any better ideas?

0 Answers
Related