[Qt-interest] Use different cursor when different modifier key is pressed

Stephen Chu stephen at ju-ju.com
Mon Nov 9 21:25:24 CET 2009


Hi

I have a custom QGraphicsItem that needs to use different cursor when 
different modifier key is pressed. For example, changes to magnify glass 
when option/alt key is pressed.

This tracking of modifiers states should only happen when the mouse is 
inside of the item. And it can not remove keyboard focus from other 
widgets in the same window.

I added hoverEnterEvent(), hoverLeaveEvent(), and hoverMoveEvent() to my 
item and it does get those events after setAcceptHoverEvents(true). But 
it doesn't get called when the mouse is in the item and not moving but 
user presses or releases keys.

keyPressEvent() and keyReleaseEvent() are never called even after 
calling grabKeyboard() in hoverEnterEvent().

Any idea?

Thanks.

-- 
Stephen Chu



More information about the Qt-interest-old mailing list