PDA

View Full Version : QPixmap png transparency



rspock
13th March 2013, 13: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, 14:22
You have to paint it on something else than white background :)

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

droneone
13th March 2013, 17: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, 17: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, 18: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, 22:57
.. or you are viewing your image on top of a white background.

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

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