本文介绍了QRadioButton 在选定和取消选定的 Qt 上的颜色变化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将选中和取消选中的单选按钮的颜色更改为QtStylesheet : 仔细.它描述了您需要的一切.它甚至几乎描述你的情况,唯一的区别是图像而不是颜色.

您案例的样式表如下:

QRadioButton {背景颜色:灰色;白颜色;}QRadioButton::指示器{宽度:10px;高度:10px;边框半径:7px;}QRadioButton::indicator:checked {背景颜色:红色;边框:2px纯白色;}QRadioButton::indicator:unchecked {背景颜色:黑色;边框:2px纯白色;}

i am trying to change the color of radiobutton on selected and deselected asQtStylesheet :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 :

解决方案

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;
}

这篇关于QRadioButton 在选定和取消选定的 Qt 上的颜色变化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-27 08:26