Alt + Key, how to create QKeySequence?
Solved
General and Desktop
-
So in a previous post I've got a hot key working with:
int intHotKeyIdx(strText.indexOf(clsMainWnd::mscchHotKeyIndicator)); if ( intHotKeyIdx >= 0 ) { const QString cstrHotKey(strText.mid(intHotKeyIdx + 1, 1)); const QKeySequence cobjKeySeq(cstrHotKey); pobjAction->setShortcut(cobjKeySeq); }
Where clsMainWnd::mscchHotKeyIndicator is set to &.
This actually sets the hotkey to the letter only and doesn't require the Alt key to be depressed to action. I am now trying to fix this and failing:
int intHotKeyIdx(strText.indexOf(clsMainWnd::mscchHotKeyIndicator)); if ( intHotKeyIdx >= 0 ) { const QString cstrHotKey(strText.mid(intHotKeyIdx + 1, 1)); QByteArray arybytHotKey(cstrHotKey.toAscii()); const int cintHotKey(arybytHotKey[0]); const int cintAlt(Qt::ALT); pobjAction->setShortcut(cintAlt + cintHotKey); }