I'm now using QGraphicsView
and QGraphicsScene
for showing some charts. Depending on values of that charts (they are histograms) I change the scale. I also draw some text (they are derived from QGraphicsItem
) for showing their values like this
But I don't scale texts like charts, so it brings to a problem. If I don't scale texts, so I get it's bounding rect's real coordinates. I want to get scale of y axis for drawing texts in right positions.
So my question how may I get the scale in QGraphicsItem
or in QGraphicsScene
.
Thank you in advance.
Well, there is a solution for that. In QGraphicsScene
you can get transformation matrix like this
QTransform matrix = views().at(0)->transform();
views()
actually returns a QList
of QGraphicsView
s. After getting matrix for getting scale (for example vertical) you can do this
qreal verticalScale = matrix.m22();
Difference for getting scale in QGrapcsItem
is just
QTransform matrix = scene()->views().at(0)->transform();
And the rest is same.