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

André Somers andre at familiesomers.nl
Tue Nov 10 07:45:23 CET 2009


That means, that your QGraphicsItem will not receive the keypresses. You may
be able to fix that by making your item derive from QObject (as well as
QGraphicsItem) and then using the event filter mechanism to listen in on the
key events being send around.

 

André

 

 

Van: qt-interest-bounces at trolltech.com
[mailto:qt-interest-bounces at trolltech.com] Namens Abhishek
Verzonden: dinsdag 10 november 2009 6:03
Aan: Stephen Chu
CC: qt-interest at trolltech.com
Onderwerp: Re: [Qt-interest] Use different cursor when different modifier
key is pressed

 

HI Stephen,

if you look at Doc
http://doc.trolltech.com/4.5/qgraphicsitem.html#keyPressEvent

it says Note that key events are only received for items that set the
ItemIsFocusable
<http://doc.trolltech.com/4.5/qgraphicsitem.html#GraphicsItemFlag-enum>
flag, and that have keyboard input focus.

this might help you.
--
Abhishek.

On Tue, Nov 10, 2009 at 1:55 AM, Stephen Chu <stephen at ju-ju.com> wrote:

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
_______________________________________________
Qt-interest mailing list
Qt-interest at trolltech.com
http://lists.trolltech.com/mailman/listinfo/qt-interest




-- 
Abhishek Patil

"Imagination is more important than knowledge..." -Albert Einstein

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20091110/96bb6bbe/attachment.html 


More information about the Qt-interest-old mailing list