The first image that I printed to PDF file becomes invisible. When I print a copy of the same image to the same PDF file, it becomes visible. So the problem is only for the first copy of the image, when I paint the the same image second time or third time there is no problem.(These are not the same QPixmap objects. These are different QPixmap objects which are created from the same image file.) After painting an image, if I paint a different image for the first time, it also appears invisible.
Later, I've realised that this problem only occurs when I set the brush color of the QPainter to Qt:transparent before I call QPainter::drawPixmap(). This problem only occurs when I print to PDF file. I have attached a sample main.cpp that triggers the bug.