[Qt-interest] Unable to get sensible coordinate mappings

David Boddie david.boddie at nokia.com
Tue May 19 01:17:11 CEST 2009


Andrew Hodgkinson wrote:

> The path I took through the documentation by chance meant that the
> window/viewport solution was the first one to present itself. It has
> analogies to an approach in another system with which I'm more familiar,
> so it seemed like a decent enough solution. As a result I'd never read
> the documentation for the QGraphicsItem transformation methods since I
> wasn't using them...

I was warned against using setWindow() and setViewport() a long time ago,
and for a while it seemed that they would be deprecated. I think they were
only kept around in Qt 4 for convenience.

> It looks like the whole of QPainter's coordinate transformations
> mechanism is essentially incompatible with the coordinate mapping methods
> in QGraphicsItem. Coordinates inside a paint() routine which employs
> painter transformations effectively become different from the item's
> general local coordinates and it's up to the application to deal with
> that. Fair enough.

It's the same in the item view classes. You're given a QPainter to use and
it's up to you to make sure you give it back in basically the same state as
it was when you received it. Unfortunately, it seems that some functions
don't play nicely with the state, as you discovered.

> If the description of transformations in both the QGraphicsItem and
> QPainter documentation could refer to each other and mention this issue
> it would be handy to prevent others making the same mistake - OTOH maybe
> I'm just stupid :-D

No, I think there is a real issue. There should be a bit more information
about what you can and can't do with QPainter in situations like these.

David
-- 
David Boddie
Senior Technical Writer
Nokia, Qt Software



More information about the Qt-interest-old mailing list