如何在 Qt 中更改 QCheckBox 文本标签颜色?

2021-12-23 00:00:00 qt checkbox qcheckbox c++

我无法在 QT 中更改 Qcheckbox 的颜色,有人可以帮我编写代码来更改复选框文本标签的颜色.我试过 Qpalette.. 而我使用的是 QT4.7.4 版本..

I'm unable to change the color of Qcheckbox in QT, can somebody help me with code to change color of check box text label. I have tried Qpalette.. And im using QT4.7.4 version..

推荐答案

你可以使用 样式表.

例如:

checkBox->setStyleSheet("QCheckBox { color: red }");

有关详细信息,请查看 Qt 参考中的样式表 和样式表文档

For more details check the style sheets in Qt Reference and the stylesheets documentation

相关文章