Details
-
Bug
-
Resolution: Done
-
P3: Somewhat important
-
5.12.3, 5.13.0
-
-
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.