I've already been down that route of using the QKeySequence toString method. Sure, it comes out in a format like Ctrl+Shift+ScrollLock but that doesn't transfer over easily into the corresponding Qt::key_scrollLock. Unless I do a gigantic bunch of if statements...
QString key
= "ScrollLock";
//for example sake if ( key == "A")
return Qt::Key_A;
if ( key == "B")
return Qt::Key_B;
...
if ( key == "F1")
return Qt::Key_F1;
...
if ( key == "ScrollLock")
return Qt::Key_scrollLock;
QString key = "ScrollLock"; //for example sake
if ( key == "A")
return Qt::Key_A;
if ( key == "B")
return Qt::Key_B;
...
if ( key == "F1")
return Qt::Key_F1;
...
if ( key == "ScrollLock")
return Qt::Key_scrollLock;
To copy to clipboard, switch view to plain text mode
That really seems a bit tedious and messy, cause I would need to do that for each and every possible key the user could press. What I'm hunting for is a quicker way. I wonder if I could do something like:
int modifiers = 0xFF00;
modifiers &= seq; //mask out modifiers
int qKey = 0x00FF;
qKey &= seq;
QKeySequence seq = QKeySequence( "Ctrl+Shift+ScrollLock");
int modifiers = 0xFF00;
modifiers &= seq; //mask out modifiers
int qKey = 0x00FF;
qKey &= seq;
To copy to clipboard, switch view to plain text mode
Ultimately for the RegisterHotKey() I need to translate the QKeySequence into modifiers (that part is easy) and into the individual keys as virtual keys (the MS way).
Paul
Bookmarks