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

Stephen Chu stephen at ju-ju.com
Tue Nov 10 16:33:39 CET 2009


In article <4AF9839F.7020407 at familiesomers.nl>,
 Andre Somers <andre at familiesomers.nl> wrote:

> 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#GraphicsIte
> >> mFl
> >> 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.

QGraphicsView doesn't seem to get keyPress/Release events. So I 
installed the filter to the window and it works pretty well now.

Thanks for the help. On to find my next question. :)

-- 
Stephen Chu



More information about the Qt-interest-old mailing list