1
votes

I am using a QTableWidget with multiple columns.. One column is for the filename which is very long so I have to stretch the column every time.Is there any method by which i can sort out this problem???

1

1 Answers

0
votes

You can use the inherited functions:

void QTableView::resizeColumnsToContents();

or

void QTableView::resizeColumnToContents (int column);

every time you changed the filename. That should be faster and easier than stretching it according to the filename's length.


You can also try using setResizeMode:

tableWidget->horizontalHeader()->setResizeMode(QHeaderView::ResizeToContents);

I've never used it, but it looks promising. This should make the columns resize automatically,