Question

I want to edit image in Qt application, I have use two QLabel and set two different image(using QPixmap) on each, now I wan to set one image over another(just like photo DJ set new Frame and Add Cartoons to Image).
I use drag and drop for this and I am able to move (drag) image, but this dragged image override another image. I want dragged image over second image and set position of dragged image on second image not override it. I have added image that I want(Edit Image). alt text

Was it helpful?

Solution

To render the first image over the second, try something like

QPixmap background(":/dj.jpg");
QPixmap object(":/fish.png"); //a png with transparent background
QPixmap merge = background.copy();
QPainter painter(&merge);
painter.drawPixmap(X,Y, object); //draw the fish on background at point X,Y
painter.end();
MyLabel->setPixmap(merge); //update the label

Where X,Y is set with clicks or mouse-tracking.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top