From 6da6b6da4494439dc34e92fee7d69b5ad48a783d Mon Sep 17 00:00:00 2001 From: ChunLin Wang Date: Tue, 26 Jan 2021 14:56:13 +0800 Subject: [PATCH] Fix that the placeholdertext of QCombobox is not drawn If the current index is invalid,a placeholdertext will be displayed. Fixes: QTBUG-90595 Pick-to: 6.0 5.15.2 Change-Id: Id4c6b9c959242b96ee0944b8fc3131a9a2fdcccc Reviewed-by: Christian Ehrlicher --- src/widgets/widgets/qcombobox.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/widgets/widgets/qcombobox.cpp b/src/widgets/widgets/qcombobox.cpp index 65017be384..0194b7bf52 100644 --- a/src/widgets/widgets/qcombobox.cpp +++ b/src/widgets/widgets/qcombobox.cpp @@ -3028,8 +3028,10 @@ void QComboBox::paintEvent(QPaintEvent *) initStyleOption(&opt); painter.drawComplexControl(QStyle::CC_ComboBox, opt); - if (currentIndex() < 0) - opt.palette.setBrush(QPalette::ButtonText, opt.palette.brush(QPalette::ButtonText).color().lighter()); + if (currentIndex() < 0 && !placeholderText().isEmpty()) { + opt.palette.setBrush(QPalette::ButtonText, opt.palette.placeholderText()); + opt.currentText = placeholderText(); + } // draw the icon and text painter.drawControl(QStyle::CE_ComboBoxLabel, opt);