[Qt-interest] Map to view from inside QGraphicsItem::paint()

Stephen Chu stephen at ju-ju.com
Wed Oct 21 16:40:27 CEST 2009


In article <4ADF16C4.10504 at productiveconcepts.com>,
 Josiah Bryan <jbryan at productiveconcepts.com> wrote:

> Stephen Chu wrote:
> > In article <4ADC62B8.4020901 at productiveconcepts.com>,
> >  Josiah Bryan <jbryan at productiveconcepts.com> wrote:
> > 
> >> In the absence of any responses, I experimented till I was cross-eyed 
> >> and blurry from staring at code. Finally, I came up with a workable 
> >> solution:
> >>
> >>      QRect viewRect = painter->combinedTransform().mapRect(myRect);
> > 
> > Thanks for leaving this hit. It's really helpful to a Qt newbie like me. 
> > But wouldn't the width and height of viewRect be flipped if the the 
> > scene is rotated 90 degree?
> > 
> 
> 
> Good point, Stephen. Ummm... I don't even know, hadn't thought about it. 
> I'm not doing any rotation (at the moment) in my scene, so I hadn't 
> worried about it. If I get around to it I'll try and report back here. 
> Don't know the answer to that one.
> 
> -josiah


I think using levelOfDetail in QStyleOptionGraphicsItem to scale the 
rect is probably one way to solve it.

-- 
Stephen Chu



More information about the Qt-interest-old mailing list