开发者

How do I create an image comparator in qt?

开发者 https://www.devze.com 2023-02-23 01:21 出处:网络
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. Lastl开发者

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. Lastl开发者_如何学Goy, 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消