I can draw a Line on my Qlabel by doing this:
QPixmap *myPixmap; myPixmap = new QPixmap(); myPixmap->fill(Qt::red); QPainter painter(myPixmap); painter.setPen(Qt::blue); painter.drawLine(1, 1, 50, 50); ui.label->setPixmap(*myPixmap);
That works. I get a red label with a blue line.
But now i want do draw that line over a 1.jpg like this:
QPixmap *myPixmap; myPixmap = new QPixmap(ui.label->size()); myPixmap->load("c:\\temp\\1.jpg"); QPainter painter(myPixmap); painter.setPen(Qt::blue); painter.drawLine(1, 1, 50, 50); ui.label->setPixmap(*myPixmap);
Unfortunately now i only get my 1.jpg but no blue line over it.
Can anybody explain this?I work on Win10 / QT5.6.1