I am developing a computer application with PySide, and I am using QTableWidget. Say my table has 3 columns, but the data they contain is very different, for example (for each row) a long sentence in the first column, and then 3-digit numbers in the last two columns. I would like to resize the table to adjust its size to the data , or at least to set the column sizes as (say) 70/15/15% of the available space .
What is the best way to do this?
I tried table.horizontalHeader().setResizeMode(QHeaderView.Stretch) after reading this question , but it makes 3 columns of the same size.
I also tried table.horizontalHeader().setResizeMode(QHeaderView.ResizeToContents) thanks to Fabio comment , but it doesn't fill all available space as needed.
Neither Interactive , Fixed , Stretch , ResizeToContents from the ResizeToContents documentation seems to give me what I need (see second edit).
Any help would be appreciated, even if it is for Qt / C ++! Thank you very much.
EDIT: I found a workaround, but it's still not the one I'm looking for:
header = table.horizontalHeader() header.setResizeMode(QHeaderView.ResizeToContents) header.setStretchLastSection(True)
It would be better if the setStretchFirstSection method setStretchFirstSection , but, unfortunately, it looks like it is not alone.
EDIT 2:
The only thing that can be changed in the table is the last column, the user can enter a number in it. Red arrows indicate what I would like to have.
Here's what happens with Stretch 
Here's what happens with ResizeToContents 