# HG changeset patch # User Teemu Piippo # Date 1680955699 -10800 # Node ID 3e3784c4cd3e3faf02aff29bbd167b8b7dda8293 # Parent 81cd5dee6d77b344a444558a17356d6935b423df Change color edit coloring to use only stylesheets to colorise the line edit only diff -r 81cd5dee6d77 -r 3e3784c4cd3e widgets/colorbutton.cpp --- a/widgets/colorbutton.cpp Sat Apr 08 15:05:57 2023 +0300 +++ b/widgets/colorbutton.cpp Sat Apr 08 15:08:19 2023 +0300 @@ -1,5 +1,4 @@ #include -#include #include #include "widgets/colorbutton.h" @@ -28,14 +27,12 @@ }); connect(this->lineEdit, &QLineEdit::textChanged, [&]{ const QColor color = this->color(); - QPalette palette{color}; const qreal lightness = color.lightnessF(); const QColor foreground = lightness < 0.4 ? Qt::white : Qt::black; - const auto style = QStyleFactory::create("Fusion"); - this->setStyle(style); - this->setStyleSheet(QStringLiteral( - "*{background-color: %1; color: %2;}" - ).arg(color.name()).arg(foreground.name())); + this->setStyleSheet( + QStringLiteral("QLineEdit{background-color: %1; color: %2;}") + .arg(color.name()) + .arg(foreground.name())); Q_EMIT this->colorChanged(this->color()); }); this->setColor(Qt::black);