sergio87
17th May 2011, 12:52
Hi!
I'm working with the QT Example "image viewer". Now I open an image like this:
QString fileName = QFileDialog::getOpenFileName(this,
tr("Open File"), tr("C:"));
if (!fileName.isEmpty()) {
QImage image(fileName);
if (image.isNull()) {
QMessageBox::information(this, tr("Image Viewer"),
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?
void SubQLabel::paintEvent(QPaintEvent *event){
painter.begin(this);
painter.setBackgroundMode(Qt::TransparentMode);
painter.setCompositionMode(QPainter::CompositionMo de_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
I'm working with the QT Example "image viewer". Now I open an image like this:
QString fileName = QFileDialog::getOpenFileName(this,
tr("Open File"), tr("C:"));
if (!fileName.isEmpty()) {
QImage image(fileName);
if (image.isNull()) {
QMessageBox::information(this, tr("Image Viewer"),
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?
void SubQLabel::paintEvent(QPaintEvent *event){
painter.begin(this);
painter.setBackgroundMode(Qt::TransparentMode);
painter.setCompositionMode(QPainter::CompositionMo de_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