0

I'm trying to load 2 images in Qlabel. I want overlay car image

on background image

at a specific location lets say (x,y). I'm using Qt5.5.1. I'm calculating displacement of the car. Now I want to update the displacement of car on background image. This is how I load the images on button clicked

void MainWindow::on_pushButtonLdImg_clicked()
{
    QPixmap pixmap(imagePath);
    QPixmap pixmapcar(imagePathCar);
    ui->labelMainImg->setPixmap(pixmap);
    ui->labelMainImg->setPixmap(pixmapcar);
}
eyllanesc
  • 235,170
  • 19
  • 170
  • 241
  • Two consecutive calls of `setPixmap` won't make the trick. It's either you implement your own `paintEvent()` or just use QGraphicsScene (possible overkill, depending on what you make the drawing for) – MasterAler Dec 25 '18 at 21:36
  • One way is to merge 2 images into 1: https://stackoverflow.com/questions/18998850/how-to-merge-two-images-into-one-using-qimage-and-qpainter-in-qt And other way is to add second QLabel and set pixmap of the car in the separate QLabel – Angel.Risteski Dec 26 '18 at 08:51
  • Thanks for the reply!! As per @MasterAler I have implemented my own way paintevent() using **Qpainter**. – Sanket Mahajan Jan 03 '19 at 10:29
  • @Angel.Risteski the Link you provided helped. I used **setCompositionMode** and after that **drawImage**. – Sanket Mahajan Jan 03 '19 at 10:29

0 Answers0