Properly color red checkbox labels in validation (part of #12508)

This commit is contained in:
Juergen Spitzmueller 2022-03-17 08:47:43 +01:00
parent a89ff030cf
commit b9ca608c2f

View File

@ -223,11 +223,22 @@ bool ColorSorter(ColorCode lhs, ColorCode rhs)
void setValid(QWidget * widget, bool valid)
{
if (valid) {
widget->setPalette(QPalette());
if (qobject_cast<QCheckBox*>(widget) != nullptr)
// Check boxes need to be treated differenty, see
// https://forum.qt.io/topic/93253/
widget->setStyleSheet("");
else
widget->setPalette(QPalette());
} else {
QPalette pal = widget->palette();
pal.setColor(QPalette::Active, QPalette::WindowText, QColor(255, 0, 0));
widget->setPalette(pal);
if (qobject_cast<QCheckBox*>(widget) != nullptr) {
// Check boxes need to be treated differenty, see
// https://forum.qt.io/topic/93253/
widget->setStyleSheet("QCheckBox:unchecked{ color: red; }QCheckBox:checked{ color: red; }");
} else {
QPalette pal = widget->palette();
pal.setColor(QPalette::Active, QPalette::WindowText, QColor(255, 0, 0));
widget->setPalette(pal);
}
}
}