Is there a way I can add extra ColorRole to QPalette?
-
The
QPalette::ColorRole
enum defines 20 color roles. I want to add 4 new color roles to this enum so that I can assign separate background colors to widgets based on their level in my GUI. Is there any way this can be achieved? Can I do it by subclassing QPalette?The best solution for me till now is to
setAutoFillBackground(true)
and then change the background role, e.g.setBackgroundRole(QPalette::Link)
where I have already setQPalette::Link
to my desired color. But this method interferes with the normal use ofQPalette::Link
color role which I would like to avoid. Any suggestions? I don't want to use StyleSheets, it is messy. -
Hi,
You might be better off creating a proxy style to handle your custom colors.
You need to do custom stuff anyway since Qt would not know about your custom QPalette color.
-
You do not a full custom QStyle, there's QProxyStyle for lighter weight customization.