c++ - multiple shortcut key doesn't work -


i put on multiple shortcuts on each qaction, e.g. 'l, right, space'. 'l' shortcut doesn't work. 'right' , 'space' can work.

similarly, if register 'a, b' , then, 'a' not work , 'b' work.

if use qmainwindow::eventfilter() myself, instead of using qaction::setshortcut(), shortcut keys work.

in case, of course, shortcut key text not displayed on main menu.

i tested on windows 7 x64, , qt-5.9.1

qmap<qstring, qaction*>& actions = qapp->keyactions().actions(); qmap<qstring, qkeysequence> & seqmap = qapp->keyactions().keymaps(); foreach(const qstring& name, actions.keys()) {     qaction* = actions[name];     qkeysequence seq = seqmap[name]; // e.g. qkeysequence("l, right, space")     a->setshortcut(seq);     a->setshortcutcontext(qt::applicationshortcut); } 

as name "qkeysequence" suggests, sequence of keys have pressed. string "l, right, space" means user have press 3 keys in order invoke action!

if want multiple "parallel" keys, i.e. action should react of keys, not sequence, use qaction::setshortcuts , create 1 sequence every key. (you can use qstringlist::split split string 3 keys.)


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -