Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-75315

QComboBox spacing between icon and text too narrow on high DPI screens

    XMLWordPrintable

Details

    • Windows

    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.
       

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            ev E Visser
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes