How to change text color of QCheckBox tag in Qt?

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 ..

+5
source share
4 answers

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.

+5
source

This works for me:

QPalette p = myCheckBox->palette();
p.setColor(QPalette::Active, QPalette::WindowText, green);
myCheckBox->setPalette(p);
+3
source

, "-". , none. , :

QCheckBox {
   border: none;
   color: white;
}

. . , QPushButton (http://doc.qt.io/qt-4.8/stylesheet-reference.html)

+1

, 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; }");

. , , (, , - ..).

0

All Articles