PDA

View Full Version : Zoom on QGraphicsItem question (smooth not pixalted)



wally
1st August 2011, 20:27
Background: I'm creating a paint program. I am using qgraphicsitems for the Tool to draw on the canvas with the mousePress/Move/Release events. The canvas itself is a QGraphicsItem which holds a QImage (with it's paint method calling a painter->drawImage) . When you release the mouse the the QGraphicsItem is painted on to the canvas's QImage.

My question is, when I use the QGraphicsView to zoom in and i draw with the Tool, how can I paint on the screen so that it looks 1:1? In the attached image, the curve on the left is while I am drawing with my mouse and the curve on the right is after it has been painted on to my QImage (I am currently zoomed in and the pen width was 3.0).

My code for painting just tracks the mousemovements and adds the points to a painterpath. When the scene is invalidated in the the boundingRect of my Tool's space it draws the painter path.

I hope that was clear. Any ideas?
Thanks,
Darryl

6728

wally
3rd November 2011, 18:50
Turns out that QGraphicsItem::ItemCoordinate cache is what I wanted.