Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

QRadioButton color change on Selected and deselected Qt

i am trying to change the color of radiobutton on selected and deselected as QtStylesheet :Qt Stylesheet

but In this link it only refer to Loading a Image but how could I change it color and without loading Image and change border color or styling radiobutton

the requirement is attached in the Image :

RadioButtonRequiredImage

like image 744
P Kumar Avatar asked Jan 06 '23 15:01

P Kumar


2 Answers

Read documentation carefully. It describes all you need. It even almost described your case, the only difference is images instead of colours.

Style sheet for your case is like this:

QRadioButton {
    background-color:       gray;
    color:                  white;
}

QRadioButton::indicator {
    width:                  10px;
    height:                 10px;
    border-radius:          7px;
}

QRadioButton::indicator:checked {
    background-color:       red;
    border:                 2px solid white;
}

QRadioButton::indicator:unchecked {
    background-color:       black;
    border:                 2px solid white;
}
like image 161
ilotXXI Avatar answered Jan 18 '23 08:01

ilotXXI


Setting style sheet to next works for me:

QRadioButton:checked{
    background-color: red;
}

QRadioButton:unchecked{
   background-color: black;
}

Setting style sheet to QRadioButton::indicator:checked doesn't work, because this only changes the settings of the indicator.

like image 24
kato2 Avatar answered Jan 18 '23 10:01

kato2