Skip to content

Commit

Permalink
Set the PlaceholderText color in the palette from the stylesheet as well
Browse files Browse the repository at this point in the history
The color should be used across the board, so the PlaceholderText color
should also be respecting the one passed for Text and so on.

Fixes: QTBUG-89815
Change-Id: I2accb3db35488f95a1c8ebacf2316a08ee416fac
Reviewed-by: Volker Hilsheimer <[email protected]>
(cherry picked from commit bb00b63)
Reviewed-by: Qt Cherry-pick Bot <[email protected]>
  • Loading branch information
AndyShawQt authored and Qt Cherry-pick Bot committed Jan 28, 2021
1 parent 84a4f12 commit 5a9bcf5
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/widgets/styles/qstylesheetstyle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1458,6 +1458,7 @@ void QRenderRule::configurePalette(QPalette *p, QPalette::ColorGroup cg, const Q
p->setBrush(cg, w->foregroundRole(), pal->foreground);
p->setBrush(cg, QPalette::WindowText, pal->foreground);
p->setBrush(cg, QPalette::Text, pal->foreground);
p->setBrush(cg, QPalette::PlaceholderText, pal->foreground);
}
if (pal->selectionBackground.style() != Qt::NoBrush)
p->setBrush(cg, QPalette::Highlight, pal->selectionBackground);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ private slots:
void QTBUG15910_crashNullWidget();
void QTBUG36933_brokenPseudoClassLookup();
void styleSheetChangeBeforePolish();
void placeholderColor();
//at the end because it mess with the style.
void widgetStyle();
void appStyle();
Expand Down Expand Up @@ -2229,6 +2230,21 @@ void tst_QStyleSheetStyle::highdpiImages()
QHighDpiScaling::updateHighDpiScaling(); // reset to normal
}

void tst_QStyleSheetStyle::placeholderColor()
{
const QColor red(Qt::red);
qApp->setStyleSheet("* { color: red; }");
QLineEdit le1;
QLineEdit le2;
le2.setEnabled(false);
le1.ensurePolished();
QCOMPARE(le1.palette().placeholderText(), red);
le2.ensurePolished();
QCOMPARE(le2.palette().placeholderText(), red);
le2.setEnabled(true);
QCOMPARE(le2.palette().placeholderText(), red);
}

QTEST_MAIN(tst_QStyleSheetStyle)
#include "tst_qstylesheetstyle.moc"

0 comments on commit 5a9bcf5

Please sign in to comment.