PDA

View Full Version : QPixmap png transparency



rspock
13th March 2013, 14:54
I have a png with transparency but when I run the application it became white.

Do I have to do something to set the transparency?

wysota
13th March 2013, 15:22
You have to paint it on something else than white background :)

rspock
13th March 2013, 17:51
I've a blue background and I see white at the transparency area.

droneone
13th March 2013, 18:04
Show us how you're drawing your pixmap. Are you creating a pixmap and painting it to the screen, or are you doing something with QSS?

rspock
13th March 2013, 18:41
if (!product["icon"].isEmpty()){
QPixmap* pixmap = new QPixmap(product["icon"]);
QIcon icon(*pixmap);
QSize iconSize(pixmap->width(), pixmap->height());
button->setIconSize(iconSize);
button->setIcon(icon);

button->setFixedSize(pixmap->width(),pixmap->height());
//button->setFlat(true);
}

wysota
13th March 2013, 19:47
Apart from superflous use of the new operator this code is fine. The problem has to be elsewhere (e.g. your image is not transparent).

ChrisW67
13th March 2013, 23:57
.. or you are viewing your image on top of a white background.

wysota
14th March 2013, 00:07
That's what I already suggested but OP insists the background is blue :)

ChrisW67
14th March 2013, 00:41
Indeed, please forgive my failure of early morning reading comprehension.