Hello,

I want to display Destination image transparently (about 50%) over displayed source image. I did in the following way, but I am not able to achieve.

I read two images and prepared QPixmaps for those two. I displayed first image on the screen and on MouseMoveEvent I am writing second image over first.

Can anyone help me how to display an image transparently over another?

Thanks
Wizards

Qt Code:
  1. void ImageView::OpenImage(QString path)
  2. {
  3.  
  4. QDir currentDir(path);
  5. QStringList files;
  6. files = currentDir.entryList(QStringList("*.jpg"));
  7. for(int i=0;i<files.size();i++)
  8. {
  9.  
  10. QString fileName=path+"/"+files.at(i);
  11. if(i>=2)
  12. break;
  13. images[i].load(fileName);
  14.  
  15. }
  16. m_SrcPixmap=QPixmap::fromImage(images[0]);
  17. m_DestPixmap=QPixmap::fromImage(images[1]);
  18.  
  19. update();
  20. }
To copy to clipboard, switch view to plain text mode 

Qt Code:
  1. void ImageView::paintEvent(QPaintEvent *event)
  2. {
  3. QPainter p(this);
  4.  
  5. p.drawPixmap(150,150,m_SrcPixmap.width(),m_SrcPixmap.height(),m_SrcPixmap);
  6.  
  7. }
To copy to clipboard, switch view to plain text mode 

Qt Code:
  1. void ImageView::mouseMoveEvent(QMouseEvent *me)
  2. {
  3. if(me->buttons()==Qt::LeftButton)
  4. {
  5. QPainter painter(&m_SrcPixmap);
  6.  
  7. painter.setCompositionMode(QPainter::CompositionMode_Overlay);
  8. painter.drawPixmap(me->x(),me->y(), m_DestPixmap);
  9.  
  10.  
  11. painter.end();
  12. update();
  13. }
  14.  
  15. }
To copy to clipboard, switch view to plain text mode