Set the QTableWidget's columns width to size of content when double clicking header
I have a QTTableWidget that has 5 columns. On each of the columns except the first one, if I double click the header divider between two columns, the column to the left re-sizes to fit the content of the column rows. The problem I'm having is that the if I do this on the first column, it resizes but a bit smaller than the largest text value.
Can someone help me figure out how to fix this?
Re: Set the QTableWidget's columns width to size of content when double clicking head
you can use resizeColumnToContents(). may be you can put this at the end of the slot where you are re-sizing left column.
at the end of that function or after you re-size column check if it column 0 then resizeColumnToContents();
Code:
doubleClickHandler()
{
//all your resize column code......
if(column == 0)
{
treewidget->resizeColumnToContents();
}
}