PDA

View Full Version : QPushButton color



lotek
9th May 2011, 19:52
Hello,

I have a checkable QPushButton and I'd like to change its color when checked.
I've change the palette colors accordingly, but in the checked state the button is "dimmed" (dithered) as in the attached screendump.
I am working on LINUx, application style is "Windows".

How can I get rid of this dithering?

Thanks for your help

Lykurg
10th May 2011, 06:48
It's the selection/focus rect. One way to avoid that is to subclass the buttons paint event and remove the focus state before calling the base class paint event. There are some examples in that forum on how to do that, use the search because I don't know the url right now.

lotek
11th May 2011, 16:28
Thank you,

I've already solved the problem setting the stylesheet:

"QPushButton:checked "
"{"
" background-color: yellow; "
" border-width: 2px; "
" border-style: solid; "
" border-top-color: rgb(64,64,0); "
" border-left-color: rgb(64,64,0); "
" border-right-color: rgb(96,96,0);"
" border-bottom-color: rgb(96, 96, 0); "
"}"

regards,

me :)

mahi6a1985
6th October 2012, 07:48
Thank you,

I've already solved the problem setting the stylesheet:

"QPushButton:checked "
"{"
" background-color: yellow; "
" border-width: 2px; "
" border-style: solid; "
" border-top-color: rgb(64,64,0); "
" border-left-color: rgb(64,64,0); "
" border-right-color: rgb(96,96,0);"
" border-bottom-color: rgb(96, 96, 0); "
"}"

regards,

me :)


Hi,

Can i know how to get the background color of a label.

in my App i am using a tmp variable and managing the color change.

i.e.,

int LSSIT_bgcolor;

if(!(LSSIT_bgcolor==240))
{
ui->Label_LSSIT->setStyleSheet("background-color: rgb(255, 153, 0)");
LSSIT_bgcolor=240;
}
if(LSSIT_bgcolor==240)
{
ui->Label_LSSIT->setStyleSheet("background-color: rgb(221, 221, 255)");
LSSIT_bgcolor=241;
}

Now what i need is instead a of using an extra variable like "LSSIT_bgcolor" to be used in if condition is their any other way ?
So that i can know what the color already is applied to my Label.