QKeySequence QKeyEvent enhancement request

Discuss anything related to product development
Post Reply
seasoned_geek
Posts: 254
Joined: Thu Jun 11 2020 12:18 pm

QKeySequence QKeyEvent enhancement request

Post by seasoned_geek »

In working on some enhancements to Diamond, notably adding EDT support, I walked right into a significant design flaw in Qt.

QKeyEvent doesn't have a method that returns a QKeySequence. You can only get an int for the key and the modifiers all monkey piled into another binary field. You can't construct a QKeySequence from this because order is important when comparing strings.

Code: Select all

edtWord:  Ctrl+, Num+, +
keyStr:  +, Ctrl+Num+  key:  43  modifiers:  603979776
The problem wouldn't be bad if QKeySequence had a method that returned a modifiers binary. That would actually be fantastic because one could quickly perform two binary comparisons.

I'm going to noodle on this some more. A quick look at the existing key stuff in Diamond shows the design opted to connect keyboard shortcuts to the menu. That's fine for the first key combination, but not the second. What I mean by that is you can't have two keyboard shortcuts on the same menu item.

I would think (and I've been warned about thinking before) that the simplest thing would be to add a modifiers() method to QKeySequence
seasoned_geek
Posts: 254
Joined: Thu Jun 11 2020 12:18 pm

Re: QKeySequence QKeyEvent enhancement request

Post by seasoned_geek »

Sorry,
I just noticed I posted this in the wrong section.

I'm going to sleep on it a bit tonight, but it really does look like you simply can't get there from here in any reliable manner. If I try building the string from the modifiers I can generate

Ctrl+, Alt+, Delete

But the user many have entered Alt+, Ctrl+, Delete and the string match will fail.
Post Reply