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

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

    XMLWordPrintable

Details

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

    Description

      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

      Attachments

        Issue Links

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

          Activity

            People

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

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes