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

QTableView::resizeColumnToContents() ignores header when stylesheet sets height

    XMLWordPrintable

    Details

    • Platform/s:
      Windows
    • Commits:
      ffac8995769f27fe0d68d5e0cd75716afd3d1167 (qt/qtbase/5.15)

      Description

      QTableView::resizeColumnToContents(): If a stylesheet is used to set a minimum height for a table header, the width of the header is no longer used to calculate the correct column width.

      The attached project illustrates this problem: it contains a simple table where the header text is the longest text in the column. When "Apply Stylesheet" is checked, the following CSS stylesheet is set for the application:

      "QTableView QHeaderView::section { min-height: 40px; }" 
      

      If you click on "Adjust Column Width" (which calls QTableView::resizeColumnToContents()), the new column width does not include the width of the header.
      If "Apply Stylesheet" is unchecked and no stylesheet is used by the application, clicking on "Adjust Column Width" sets the column width correctly

      According to me, QHeaderView::sectionSizeFromContents() is returning size with width as -1 and height as value set using stylesheet. Due to which, resizeColumnToContents() ignore the width of header in this case.
      Ideally, We should calculate width/height from the text if not set in the stylesheet.

        Attachments

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

          Activity

            People

            Assignee:
            sonakur Sona Kurazyan
            Reporter:
            shmittal Shveta Mittal
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Gerrit Reviews

                There are no open Gerrit changes