Search code examples
qtqt4qt5qstyleqgroupbox

Disabled QGroupBox title shadow (aka etching)


Look thoroughly at the disabled QGroupBox title (see attached image).

disabled QGroupBox

You'll notice a tiny white 1-pixel shadow under the title's letters.

It's barely noticeable on default style sheet, but it can be much more annoying if you set dark background and text color.

What can I do to disable this shadow, or at least change its color?


Solution

  • What style are you using? It looks like the 'basic' Windows style. If you want to get rid of the text shadow, you can implement your own style and change the way the text is drawn for disabled group boxes. Read more about about QStyle and how to create a custom style here. The link is for Qt 5.1, but the principle is the same for Qt 4 as well.

    An easier way would be to simply change the palette for the QGroupBox object. Change the color identified by color group QPalette::Disabled and color role QPalette::Light to any color with the alpha channel set to 0, e.g. QColor(0, 0, 0, 0). This will effectively disable the text shadow. However, it will also disable the shadow of the lines so it might not be what you want.