@Ronel_qtmaster, I need to affect the button icon. I.e. I need to have grey color of my icon instead of black for disabled button. But Qt changes it very little and icon still looks like a completely black and indistinguishable from an active button.
As of now I went with below code to adjust alpha-channel for each of images inside QIcon. Not very effecive but icons are small so I can afford it.
This way I have pretty grey icons for disabled buttons.
But if someone knows better way to do it, I would like to know.
def add_disabled_state(icon: QIcon) -> QIcon:
disabled_icons = []
for size in icon.availableSizes():
icon_image = icon.pixmap(size).toImage()
for y in range(icon_image.height()):
for x in range(icon_image.width()):
pixel_color = icon_image.pixelColor(x, y)
pixel_color.setAlpha(pixel_color.alpha() / 5)
icon_image.setPixelColor(x, y, pixel_color)
disabled_icons.append(QPixmap.fromImage(icon_image))
for disabled_image in disabled_icons:
icon.addPixmap(disabled_image, mode=QIcon.Mode.Disabled)
return icon