PDA

View Full Version : QPushButton image doesn't show transparency



rawpower
5th March 2014, 23:40
Hi,

I want to add an image to QPushButton for "normal" state and an image for "pressed" state by using StyleSheets. The issue I am having is that transparency of the image doesn't seem to work well, I see the square shape of the icon even though the icon is completely transparent.
Does anyone have a an idea why this is happening ?

Here is my stylesheet code and a screenshot of the QPushButton. You can see the square with slightly different color than the background, almost as if it's partially transparent.



QPushButton#settingsButton {
image: url(transparent_icon.png);
border:none;
outline:none;
width: 64px;
height: 64px;
}


QPushButton#settingsButton:pressed {
image: url(transparent_icon.png);

}

ChrisW67
6th March 2014, 00:57
You have applied a gradient background that is cascading down and applying to the QPushButton. A transparent icon over a gradient background shows the background.

rawpower
6th March 2014, 05:50
It does look like it but I didn't. The icon has no gradient applied. When I use [code] settingsButton.setStylesheet() [\code] then the icon is transparent and I see the background. Why is there a difference?

rawpower
6th March 2014, 15:00
So I checked this again and it seems I get transparency of the icon when I write code in .cpp. But when I write it in .qss then I don't. Any thoughts anyone?