From b9ca608c2f7ca2e1434e8e7cfc9e9c83f643c6c4 Mon Sep 17 00:00:00 2001 From: Juergen Spitzmueller Date: Thu, 17 Mar 2022 08:47:43 +0100 Subject: [PATCH] Properly color red checkbox labels in validation (part of #12508) --- src/frontends/qt/qt_helpers.cpp | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/frontends/qt/qt_helpers.cpp b/src/frontends/qt/qt_helpers.cpp index 118903214c..8372fd96c5 100644 --- a/src/frontends/qt/qt_helpers.cpp +++ b/src/frontends/qt/qt_helpers.cpp @@ -223,11 +223,22 @@ bool ColorSorter(ColorCode lhs, ColorCode rhs) void setValid(QWidget * widget, bool valid) { if (valid) { - widget->setPalette(QPalette()); + if (qobject_cast(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(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); + } } }