Details
-
Bug
-
Resolution: Fixed
-
P2: Important
-
None
-
5.12.3, 5.12.4, 5.13.2, 5.15.0
-
None
Description
The QCommonStyle does not take the resolution of the screen into account when calculating the margin between an icon and the text in a QComboBox. It uses a hardcode value of 4 pixels; as shown in the code of QCommonStyle::drawControl() method:
iconRect.setWidth(cb->iconSize.width() + 4);
iconRect = alignedRect(cb->direction,Qt::AlignLeft | Qt::AlignVCenter,iconRect.size(), editRect);
if (cb->editable)
p->fillRect(iconRect, opt->palette.brush(QPalette::Base));
proxy()->drawItemPixmap(p, iconRect, Qt::AlignCenter, pixmap);
if (cb->direction == Qt::RightToLeft)
editRect.translate(4 - cb>iconSize.width(), 0);
else
editRect.translate(cb->iconSize.width() + 4, 0);
Code to visualize this problem:
QPixmap pixmap(32,32);
pixmap.fill(QColor(0xFF,0x00,0x00));
const QIcon icon(pixmap);
QComboBox combobox;
combobox.addItem(icon,"Too close");
combobox.show();
This produces the attached image.