summaryrefslogtreecommitdiffstats
path: root/src/widgets
diff options
context:
space:
mode:
authorChunLin Wang <wangchunlin@uniontech.com>2021-01-26 14:56:13 +0800
committerQt Cherry-pick Bot <cherrypick_bot@qt-project.org>2021-01-27 07:06:52 +0000
commit191e1bbf37c44aff8b208947754b9000a679912d (patch)
treede7fc0736265609b85dd69df90e71ca0183c5ff0 /src/widgets
parent39da07a4d3d9eb27845c4dd01df0d3b99ab80ede (diff)
Fix that the placeholdertext of QCombobox is not drawn
If the current index is invalid,a placeholdertext will be displayed. Fixes: QTBUG-90595 Change-Id: Id4c6b9c959242b96ee0944b8fc3131a9a2fdcccc Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de> (cherry picked from commit 6da6b6da4494439dc34e92fee7d69b5ad48a783d) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src/widgets')
-rw-r--r--src/widgets/widgets/qcombobox.cpp6
1 files 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);