I can’t change the color Qcheckboxin QT , can someone help me with the code to change the color of the checkbox text label. I tried Qpalette.. And I used the QT4.7.4 version ..
Qcheckbox
Qpalette
You can use style sheets :
checkBox->setStylesheet("QCheckBox { color: red }");
See the style sheets in the Qt Reference and the style sheet documentation for more information.
This works for me:
QPalette p = myCheckBox->palette(); p.setColor(QPalette::Active, QPalette::WindowText, green); myCheckBox->setPalette(p);
, "-". , none. , :
QCheckBox { border: none; color: white; }
. . , QPushButton (http://doc.qt.io/qt-4.8/stylesheet-reference.html)
, Qt5 (5.2, 5.4). , Pseudo-States: http://doc.qt.io/qt-4.8/stylesheet-reference.html#list-of-pseudo-states
:
myCheckbox->setStyleSheet("QCheckBox:unchecked{ color: red; }QCheckBox:checked{ color: red; }");
. , , (, , - ..).