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

Andre Somers andre at familiesomers.nl
Tue Nov 10 16:15:43 CET 2009


Stephen Chu wrote:
> In article 
> <214b3fc60911092103t5980b38cw2759f96c82e29807 at mail.gmail.com>,
>  Abhishek <abhishekworld at gmail.com> wrote:
>   
>> 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#GraphicsItemFl
>> ag-enum>flag,
>> and that have keyboard input focus.
>> *
>>     
>
> Thanks. I tried that. It works only after the user clicks at the item. 
> I'd like to skip the click part.
>
> In article <hdb270$ah0$1 at eple.troll.no>,
>  André Somers <andre at familiesomers.nl> wrote:
>
>   
>> 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.
>>     
>
> Yes. I think that's the way to go. But which object should I install the 
> event filter to?
>   
That depends on your application, and you're not telling much about it. 
You could even install it on your application object, if you'd like this 
to work application wide. Otherwise, perhaps the QGraphicsView would be 
a good candicate? That may work well, but if you have more than one view 
on the scene, that will be a problem.

André




More information about the Qt-interest-old mailing list