Details
-
Bug
-
Resolution: Out of scope
-
P3: Somewhat important
-
4.2.3
-
None
Description
It seems the QComboMenuDelegate used in QComboBoxes doesn't respect a lot of the data roles.
A patch like this makes it work better (there are other roles) that maybe should be respected as well:
— /tmp/tmp.20535.0 2007-04-02 16:04:26.000000000 -0700
+++ /home/anders/dev/qt-4.3/src/gui/widgets/qcombobox.cpp 2007-04-02 16:02:44.000000000 -0700
@@ -67,6 +67,11 @@ QStyleOptionMenuItem QComboMenuDelegate:
{
QStyleOptionMenuItem menuOption;
menuOption.palette = QApplication::palette("QMenu");
+ const QColor col = qVariantValue<QColor>(index.data(Qt::TextColorRole));
+ if (col.isValid())
+
menuOption.state = QStyle::State_None;
if (mCombo->window()->isActiveWindow())
menuOption.state = QStyle::State_Active;
@@ -94,10 +99,14 @@ QStyleOptionMenuItem QComboMenuDelegate:
extern QHash<QByteArray, QFont> *qt_app_fonts_hash();
// Make sure fonts set on the combo box also overrides the font for the popup menu.
- if (mCombo->testAttribute(Qt::WA_SetFont))
+ const QVariant font = index.data(Qt::FontRole);
+ if (!font.isNull()) { + menuOption.font = qVariantValue<QFont>(font); + }else if (mCombo->testAttribute(Qt::WA_SetFont))
{ menuOption.font = mCombo->font(); - else + }else
{ menuOption.font = qt_app_fonts_hash()->value("QComboMenuItem", mCombo->font()); + }
menuOption.fontMetrics = QFontMetrics(menuOption.font);
Update: This bug is not yet confirmed; the fix above is straight-forward but gives inconsistent behavior as items in the menu may differ from the current item.