简体   繁体   中英

How do I create an image comparator in qt?

I have two images--img1 and img2--and I would like to be able to compare both images. I would like to overlay them over each other with a slider which would let me see more of img1 or img2. Lastly, when I move in one image I would also like to move in the other img. This is what I have so far.

QGraphicsScene *scn = new QGraphicsScene( this );
ui->view->setScene( scn );
QPixmap *im = new QPixmap("P3C.jpg");
QPixmap *i = new QPixmap("result.jpg");
scn->addPixmap( *im );
scn->addPixmap(*i);

Use QGraphicsItemGroup to group the 2 pixmap items so they will act as one. Set the item group to ItemIsMovable so you can move them.

Set the opacity of the item that is on top of the other so the bottom one can show thru. You can connect the value change signal of your slider widget to your object's slot to control the opacity.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM