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

QHeaderView.paintSection text doesn't account for DecorationRole icon width

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: P3: Somewhat important P3: Somewhat important
    • 5.11.0 Alpha
    • 5.9.1, 5.10.0 Alpha
    • Widgets: Itemviews
    • None

      When QHeaderView paints the section, when eliding text, it doesn't account for the extra width taken by the DecorationRole icon.

      https://github.com/qt/qtbase/blob/e4c39d5e1e7ee8c2bba273e6d613ec519b7fa9c2/src/widgets/itemviews/qheaderview.cpp#L2754-L2771

      The fix would be to first get the icon, if any, and add the icon's pixmap's width to the text margin, i.e.

      if (!opt.icon.isNull())
          margin += get_pixmap_width(opt.icon)
      
      if (d->textElideMode != Qt::ElideNone)
          ...
      

      I don't know how to get actual pixmap width from QIcon as it probably depends on the dimensions of the underlying header item

      Probably related issue: https://bugreports.qt.io/browse/QTBUG-30116

        1. qtbug_30116_62091.tgz
          2 kB
          Christian Ehrlicher
        2. headerview_elide.png
          22 kB
          Christian Ehrlicher
        For Gerrit Dashboard: QTBUG-62091
        # Subject Branch Project Status CR V

            richard Richard Moe Gustavsen
            kernc Kernc
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes