View Full Version : Automatic sizing of QTableWidget's cells

Artem Anisimov
4th September 2006, 19:53
I try to create the QTableWidget with the number of columns and rows specified at the moment of creation and then populate its cells with widgets using setCellWidget().

It works except for one moment: the widget is resized to fit the cell. I tried setting the widget's minimal size, but it resulted in a really bad outcome: the cell size remained the same, and widgets started overlapping, creating a total mess in the table.

Is there a way to make Qt set the height of rows and width of columns so that the biggest widget fits well?

4th September 2006, 19:57
You can try checking the sizeHint of all the cells, and with this set the minimum size of both the columns and rows

Artem Anisimov
4th September 2006, 20:01
I found the solution: the QTableView has resize{Rows,Columns}ToContents() functions.

I should read mans more attentively:o .