Qt: How to display Ctrl+W instead of Ctrl+F4 in the default system menu of a subwindow? -


some quick needed, missing trick situation in qt (i use latest qt 4).

within qmdiarea, create few subwindows. subwindows have default system menu attached (minimize, maximize, stay on top, close, ... - that's seen when right-clicking on subwindow icon).

to consistent have defined in main menu of application (ctrl+w visible closing windows), i cannot accept displayed shortcut related close ctrl+f4 in subwindows' system menu. it has ctrl+w. have tried different things, including setting shortcut global application (with setshortcutcontext)... no luck.

close has default 2 shortcuts: ctrl+w , ctrl+f4. want both keep working, it's ctrl+w should displayed.

for now, solution see replace system menu (a qmenu)... seem lot of code such simple task!

you can try setting way:

ui->mdiarea->subwindowlist().at(index)->systemmenu()->actions().last()->setshortcut(qkeysequence(qt::ctrl + qt::key_w)); 

please replace "index" suitable index. worked me. (update: not work, ctrl+w assigned shortcut close action)

update:

close action has 2 assigned shortcuts, , first 1 displayed @ menu. if swap order, you'll ctrl+w displayed.

qlist<qkeysequence> closeshorcuts = ui->mdiarea->subwindowlist().at(0)->systemmenu()->actions().last()->shortcuts(); closeshorcuts.swap(0, 1); ui->mdiarea->subwindowlist().at(0)->systemmenu()->actions().last()->setshortcuts(closeshorcuts); 

please note there no platform check in source code; if run on mac you'll opposite result, , in x11 go out of list bounds (because there 1 shortcut: ctrl+w).


Comments

Popular posts from this blog

objective c - Change font of selected text in UITextView -

php - Accessing POST data in Facebook cavas app -

c# - Getting control value when switching a view as part of a multiview -