Change disabled QIcon tint color
Asked Answered
D

1

8

I have an application with a custom theme and the disabled icons are to brightly grayed. I would like to change the disabled icon tint color.

Now I know there is a possibility like this:

QTableWidgetItem *name = new QTableWidgetItem("test");
QIcon icon("toto.png");
icon.addPixmap(QPixmap("toto.png"),QIcon::Disabled);
name->setIcon(icon);

but I have a lot of icons and I wouldn't want to create another set of icons just for the disabled state.

Isn't it possible to change the QIcons' tint color from tinted gray to red or black or any other color?

Dareen answered 16/6, 2015 at 10:36 Comment(0)
T
8

You can define your own QProxyStyle and override the generatedIconPixmap method.

This method is responsible for generating derived pixmaps for different icon states

Tip answered 16/6, 2015 at 10:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.