Unsolved Qpainter scale existing drawing not working
-
void CanvasWidget::drawData(float x,float y,float z) { QPainter painter(&canvasImage); painter.drawPoint(x, y); }
Code for plotting point working fine
void CanvasWidget::mouseReleaseEvent(QMouseEvent *event) { QPainter painter(&canvasImage); QTransform transform; transform.scale(5,5); painter.setTransform(transform); this->update(); }
Painter scale property not working
I just want to zoom the draged portion. -
Hi,
These are two different painters, why should the transform apply ?
-
Also, I thought that all widget painting must be done in the paintEvent?
-
That's correct. My question is why would the painter you create and modify in the mouseReleaseEvent method have any influence on the painting you do in the paintEvent ?
-
I agree. The transform should be created and saved, then used in the paintEvent.
-
@SGaist I want to zoom the dragged portion
-
@sujith-D
This is my painter screen, there is a blue rectangle(dragged portion). I just want to zoom that dragged portion.
@SGaist I was using different painters for drawing this single picture. first painter is used for creating the background and second painter is used for creating the grid lines. Both are applaide on the same CanvasWidget. -
But you are not using the other painter. You can draw on a QImage at any time but you are currently just creating a painter and do nothing with it.
Looks like you should setup everything and then do the painting.