Stylesheet for disabled QPushButton under Win XP
-
Hi guys,
in my Qt 5.5.1 application under Windows XP Home SP3, the QPushButtons got a drop-shadow in disabled style (see screenshots). Any ideas how to get rid of this effect? I would prefer a solution via stylesheet, but any help is greatly appreciated.
I already found this old thread on quite the same topic, but the suggested solution did not work:
https://forum.qt.io/topic/20803/stylesheet-for-disabled-qpushbutton-under-windows-7-basic-themeMy stylesheet code:
QPushButton { background-color: #999; color: #FFF; border-image: none; border-style: outset; font-weight: bold; font-family: "Arial"; font-size: 10pt; min-height: 33px; padding: 0px 10px; } QPushButton:disabled { background-color: #BBB; color: #D8D8D8; /* reps. #F00 in screenshot 2 */ }
Screenshot 1:
https://www.dropbox.com/s/lb9sp0932ujqn0c/WinXP_QPushButton_EnabledDisabled_gray.png?dl=0Screenshot 2 (just for clarification):
https://www.dropbox.com/s/mytpi8ms03esqpv/WinXP_QPushButton_EnabledDisabled_red.png?dl=0 -
Hi @PatrickS
Are you sure , that all stylesheet is defined in this piece:
QPushButton { background-color: #999; color: #FFF; border-image: none; border-style: outset; font-weight: bold; } QPushButton:disabled { background-color: #BBB; color: #D8D8D8; /* reps. #F00 in screenshot 2 */ }
Don't you have any other stylesheet code?
-
Hi @mostefa ,
thanks for your answer.
Of course there is much more stylesheet code used in my application, but the problem is reproducable with this snippet. To make the buttons look exactly like on the screenshots, just font-family, font-size, min-height and some padding need to be added (the width is done by a QGridLayout); I've updated the code in my first post accordingly.
-
@PatrickS said in Stylesheet for disabled QPushButton under Win XP:
Hi @mostefa ,
thanks for your answer.
Of course there is much more stylesheet code used in my application, but the problem is reproducable with this snippet. To make the buttons look exactly like on the screenshots, just font-family, font-size, min-height and some padding need to be added (the width is done by a QGridLayout); I've updated the code in my first post accordingly.
i have just tested your code in windows7 and linux and i am not having this problem, and i don't have win XP to test :(,
Can you try to delete (Temporarily) your stylesheet for app , and keep only this part :
QPushButton { background-color: #999; color: #FFF; border-image: none; border-style: outset; font-weight: bold; font-family: "Arial"; font-size: 10pt; min-height: 33px; padding: 0px 10px; } QPushButton:disabled { background-color: #BBB; color: #D8D8D8; /* reps. #F00 in screenshot 2 */ }
This kind of effect remember me one similar problem , and this was due to double stylesheet definition in different places, i don't know but this can be the same thing for you?
-
Thanks for testing! On Windows 10, everything looks fine too, it just seems to be Windows XP causing this problem.
Some time ago, I had a similar case with borders around QFrames: They need to be set explicitely to "none", otherwise they will be shown by default - but only on Windows XP, on no other OS!My current guess is that some sort of Win XP-only default stylesheet is applied here because I missed something in my CSS code...
Yep I've already tested to reduce the stylesheet on just the snippet, problem persists :-(
-
Ok I made some progress by myself; the problem doesn't seem to be new:
http://www.qtcentre.org/threads/36417-disabled-QCheckBox-text-stylesheet-how-to-get-rid-of-change-color-of-etch-effect
http://www.qtcentre.org/threads/11475-Does-etch-disabled-text-work
http://stuffnobodytoldmeabout.blogspot.de/2012/05/pesky-etching.htmlBut unfortunately, neither the suggested sollution to edit the palette in the C++ code like this:
QPalette p = QApplication::palette(); p.setColor(QPalette::Disabled, QPalette::Light, QColor(0, 0, 0, 0)); QApplication::setPalette(p);
does work for me, nor this ominous stylesheet entry:
QPushButton:disabled { etch-disabled-text: 0; }
Anyone got another idea?
Update:
The color of the text shadow seems to be always about 15% brighter (referred to the RGB values) than the color of the disabled QPushButton's background...