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:
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.