From b3eac3f43b087ee7939a607cd8a6e5ed398f6716 Mon Sep 17 00:00:00 2001 From: Jens Bache-Wiig Date: Mon, 29 Mar 2010 16:22:52 +0200 Subject: Fix QComboBox ignoring foreground role in some styles Basically all styles using SH_Combobox_Popup would not previously respect the foreground role set. We need to set it for multiple color roles since styles sometimes interpret them differently. Reviewed-by: ogoffart Task-number: QTBUG-8796 --- src/gui/widgets/qcombobox.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/gui/widgets/qcombobox.cpp b/src/gui/widgets/qcombobox.cpp index c16f18a..b1a27f2 100644 --- a/src/gui/widgets/qcombobox.cpp +++ b/src/gui/widgets/qcombobox.cpp @@ -108,7 +108,15 @@ QStyleOptionMenuItem QComboMenuDelegate::getStyleOption(const QStyleOptionViewIt const QModelIndex &index) const { QStyleOptionMenuItem menuOption; - menuOption.palette = option.palette.resolve(QApplication::palette("QMenu")); + + QPalette resolvedpalette = option.palette.resolve(QApplication::palette("QMenu")); + QVariant value = index.data(Qt::ForegroundRole); + if (qVariantCanConvert(value)) { + resolvedpalette.setBrush(QPalette::WindowText, qvariant_cast(value)); + resolvedpalette.setBrush(QPalette::ButtonText, qvariant_cast(value)); + resolvedpalette.setBrush(QPalette::Text, qvariant_cast(value)); + } + menuOption.palette = resolvedpalette; menuOption.state = QStyle::State_None; if (mCombo->window()->isActiveWindow()) menuOption.state = QStyle::State_Active; -- cgit v0.12