设置选中后的qcheckbox背景色和对勾颜色
时间: 2024-03-13 16:45:37 浏览: 171
您可以使用CSS来设置QCheckBox选中时的背景色和对勾颜色。以下是一个示例:
```
QCheckBox::indicator:checked {
background-color: #007acc;
border: none;
}
QCheckBox::indicator:checked:disabled {
background-color: #c8c8c8;
border: none;
}
QCheckBox::indicator:unchecked {
background-color: transparent;
border: 1px solid #c8c8c8;
}
QCheckBox::indicator:unchecked:disabled {
background-color: transparent;
border: 1px solid #c8c8c8;
}
QCheckBox::indicator:checked::indicator:checked {
image: url(checked.png);
}
QCheckBox::indicator:unchecked::indicator:unchecked {
image: url(unchecked.png);
}
```
其中,`QCheckBox::indicator:checked`设置了选中时的背景色和去掉边框,`QCheckBox::indicator:checked:disabled`设置了选中且不可用时的背景色和去掉边框,`QCheckBox::indicator:unchecked`设置了未选中时的边框颜色,`QCheckBox::indicator:unchecked:disabled`设置了未选中且不可用时的边框颜色。`QCheckBox::indicator:checked::indicator:checked`设置了选中时的对勾颜色,`QCheckBox::indicator:unchecked::indicator:unchecked`设置了未选中时的对勾颜色。
您可以根据需要自定义这些颜色和图片。
阅读全文