I have a QTableView
where I use the following code:
h_header = self.horizontalHeader()
h_header.setSectionResizeMode(QHeaderView.ResizeMode.ResizeToContents)
h_header.setStretchLastSection(True)
My problem is now that this limits the width of the content to the width of the widget, and replaces the content of columns that are too long with "...".
When I remove setStretchLastSection(True)
then it shows longer content with a horizontal scrollbar, but shorter content with empty space on the right.
Is there a way to only stretch the table if the content is less wide than the widget, but else show the complete content with a scrollbar?
Thanks.