Trolltech Home | Qt-interest Home | Recent Threads | All Threads | Author | Date
All threads index page 3

Qt-interest Archive, February 2007
QGraphicsView and scaling


Message 1 in thread

Hi,

I today tried the scaling feature of QGraphicsView and I was very surprised at 
how nicely it worked! As my graphics is now mostly SVG it all scales very 
nicely too, no jaggies anymore. It became very apparent which items are still 
pixmap based after some zooming in. :)

Anyway, the scaling is accumulative, ie it adds to the previous scaling, 
meaning a scaling of 2.0 and then 2.0 means it's all scaled by 4.0. Should I 
manually keep track of the total scaling level I've set or can I somehow get 
it from QGraphicsView? I see to find nothing in the API related to this. What 
I'm mostly interested in is providing the user with a few predefined scaling 
levels, such as 25%, 50%, 100%, 200% and 300%. Also important would be a way 
to get back to 100% scaling level would the user somehow zoom in/out too far 
and get lost.

A way to get the current set scaling level would be welcome. I guess it can be 
extracted from the view matrix somewhow, but I have no real idea how. or have 
I overlooked something simple?

Best regards,
    Jan Ekholm

-- 
 [ signature omitted ] 

Message 2 in thread

On Saturday 10 February 2007 13:05, Jan Ekholm wrote:

> Also
> important would be a way to get back to 100% scaling level would the user
> somehow zoom in/out too far and get lost.

Ok, resetting the scaling level was quite easy after all, just call:

    view->setMatrix(QMatrix());  // or even this: view->resetTransform();

Apparently the matrix seems to contain the zoom level directly in m11 and m22 
so it should be quite easy to do what i want. Some convenience methods for 
extracting the current scaling, rotation and translation values could be nice 
to have.

Some more RTFM seems to be in order for me.

-- 
 [ signature omitted ]