I have a QTableView with a horizontal header and a couple of columns. I would like to set the width of the table view to exactly show all the columns in their correct width. (So I do not want to setStretchLastSection(true)).

I've tried lots of combinations of size policies, resizing, etc.

Could someone tell me how to do this?

Thanks in advance,
Martin