[SOLVED] QGraphicsView and scale
General and Desktop
7
Posts
4
Posters
11.8k
Views
1
Watching
-
Graphics view has function scale(qreal,qreal) which scales objects inside it. How to get scale factor of my view ? I found that I cam get transformation matrix using transformation() function, but how can I get factor value using this or maybe other ideas ?
-
I know this topic is quite old, but I want to update the solution. I used the solution from dakron but got weird behavior sometimes.
m11 for x and m22 for y works only if the view has no rotation applied. If the view is rotated the returned values will be wrong.
You can calculate the x scale with 'sqrt(trf.m11() * trf.m11() + trf.m12() * trf.m12())' (pythagoras, where trf is the QTransform) and y with 'sqrt(trf.m21() * trf.m21() + trf.m22() * trf.m22())'.