[PyQt] painter help

Matthew Ngaha chigga101 at gmail.com
Sat Mar 9 15:16:35 GMT 2013

Hi im trying to use the QPainter to draw some Pixmaps but the problem
is one pixmap has a big white background that makes it not blend into
the program and its clear to see this was an external image thrown in.
I have looked at various ways to remove the white background/outline
of the image. so far i found:

pixMap = QPixmap(pix)
pixMap.createMaskFromColor(Qt.white, Qt.MaskOutColor)

The classes reference says passing in the colour into the 1st argument
and choosing Qt.MaskOutColor removes the colour from the image, but
this has had no effect on my pixmap.

my 2nd attempt was a bit better but still not what i want:

pixMap = QPixmap(pix)

This did remove the white outline/background in the pixmap but it also
badly smudged the whole image, and its not as clear to see anymore as
the original pixmap. Is there something i'm missing? how can i remove
or make a color transparent? Also painter.setOpacity(i) is no good for
i wondered if there was a way to get a QPoint() and have PyQt retrieve
the colour value for that specific point, maybe then
QPixmap.pixMap.createMaskFromColor() would work for me?

More information about the PyQt mailing list