Insert/Delete points over image
Hi!
I'm working with the QT Example "image viewer". Now I open an image like this:
Code:
tr("Open File"), tr("C:"));
if (!fileName.isEmpty()) {
if (image.isNull()) {
tr("Cannot load %1.").arg(fileName));
return;
}
imageLabel
->setPixmap
(QPixmap::fromImage(image
));
}
imageLabel is QLabel.
Well, I want to draw something (circle, ellipse...) on the image every time I clicked (at mouse position). I have the mouse position (x, y). But I can't draw nothing. I would still see the image.
What I've done?
Code:
painter.begin(this);
painter.setBackgroundMode(Qt::TransparentMode);
painter.
setCompositionMode(QPainter::CompositionMode_DestinationOver);
painter.drawEllipse(10,10,10,10);
painter.end();
}
I subclased the QLabel I I override the paintEvent. But the image dissapears and it shows the Ellipse with white background.
I would like to put a lot of points and delete this points on image.
How can I do that? :confused:
Thanks!!!!! :D:D:D
Re: Insert/Delete points over image
Quote:
But the image dissapears and it shows the Ellipse with white background.
Because now the paintEvent() is only painting the ellipse.
Add QLabel::paintEvent(event); before your drawing code.
Re: Insert/Delete points over image
try calling QLabel::Paint at the beginning of ur subclassed method
Re: Insert/Delete points over image
Thanks!!! :D
It works!!. I'm going to try if I can draw an ellipse and then detele it. The code is:
Code:
painter.begin(this);
painter.drawEllipse(10,10,10,10);
painter.end();
}
Painter is QPainter.
Also I'm going to try how can I scale the ellipse at the same time I scale the image.
Thank you very much!!! :D