Paint Event and Zoomed In Image Problem
-
Hi, I'm working on a project where I have to do an image editor similar to Paint. I would like to open up an image, zoom in/zoom out if necessary, and then draw on it. For that, I used Image Viewer and Scribble examples, and created a QLabel subclass that is supposed to draw lines and other forms with the mouse button.
The problem is, when I open my image, I'm able to zoom on it normally:
But when I want to draw something it resizes the image to it's original size, but keeps labels zommed in's size:
I believe that it has something to do with the overriden paintEvent that I use to draw, here's it's code:
void imLabel::paintEvent(QPaintEvent *event){ if(tipo != ""){ //draw mode QPainter painter(this); QRect dirtyRect = event->rect(); painter.drawImage(dirtyRect,image,dirtyRect); } else QLabel::paintEvent(event); }
Is there a way that I can keep the image zoomed in while I draw, just like in Paint?
-
Hi
How do you zoom it, in the first place ?
If its just by making label bigger, then maybe(still in paintEvent)
if(tipo != ""){ //draw mode QPainter painter(this); QRect fullRect = rect(); // use rect of label painter.drawImage(dirtyRect,image,fullRect ); }