Quantcast
Viewing latest article 11
Browse Latest Browse All 58

draw with QPaint on loaded QPixmap does not work

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


Viewing latest article 11
Browse Latest Browse All 58

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>