[Qt-interest] ShortCuts + QMenu + QGraphicsTextItem

John Clayton johnclayton72 at gmail.com
Thu Oct 29 01:03:06 CET 2009


Hi All,

I've got an app that has a QMenu containing QActions for various  
things (undo and redo, cut, paste - that kind of thing).  This all  
works fine, as long as no other object wants to make use of undo/redo  
shortcut combinations.

Therein, lies the problem.

I've recently added a QGraphicsTextItem to my program - and when the  
text item is in editing mode, it also has the ability to use:
	undo, redo
	select all
	cut / copy / paste

The shortcut/accelerator modifiers are the same for these actions.

When I press the shortcut key to activate any of these shortcuts - the  
QMenu based action is triggered, not the shortcut of the  
QGraphicsTextItem - even though the item with the focus is the  
QGraphicsTextItem.

So I'm wondering: what's the best way to ensure that the  
QGraphicsTextItem gets the shortcut event, and not the menu?

The only way I can think of that's going to work reliably is to  
disable the shortcuts in the QMenu before going into edit mode with  
the QGraphicsTextItem - but that feels like a rather large hack to me,  
so I'm hoping there's a better way.

Thanks for any tips - its appreciated.

--
John Clayton



More information about the Qt-interest-old mailing list