PDA

View Full Version : How do I get the scaling factor by QGraphicsViews?



lni
2nd February 2009, 21:22
From within QGraphicsItem's paint method, I need to get the scaling factor (m11 and m22) done by its viewer.

I need to undo the scaling effect done by the zoom.

I am doing cross plotting with different markers. When user zooms the plot, the markers are scaled too (just as font was scaled, undesirable features). It doesn't increase the data resolution by this, whatever was covered by other markers are still covered by those markers... that is why I need to get view's scaling factor and apply inverse scaling before redrawing...

Thanks

seneca
2nd February 2009, 22:20
QPainter::transform() should hold that information

lni
2nd February 2009, 22:45
QPainter::transform() should hold that information

But QPainter also holds the item's own scaling. I need the scaling purely from the viewer...

paint(...) has a widget id, and its parent seems to be the viewer's id which I can cast to QGraphicsView, but I wonder how reliable this is...

seneca
2nd February 2009, 23:40
From docs:


The widget argument is optional. If provided, it points to the widget that is being painted on; otherwise, it is 0. For cached painting, widget is always 0.

Does not sound as if it is very reliable.

Why not divide the overall scaling in the painter by the item scaling?