选中和取消选中 Qt 上的 QRadioButton 颜色更改 [英] QRadioButton color change on Selected and deselected Qt

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

问题描述

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

您的案例的样式表如下:

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

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 :

解决方案

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

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

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆