Alex Rivera | Logout

How to get right row height in Qt for QTableView object?

Asked 2010-09-10T18:16:56.997
9

From this screenshot you can see a lot of space inside the rows:

alt text

I've used these functions to get resizing:

resizeRowsToContents();
resizeColumnsToContents();

How can I get a better fit for cells/rows sizes?

Edit
Report

1 Answer

0

I have the same problem, so do many others it seems:

http://www.qtforum.org/article/13421/qtableview-how-to-make-rows-size-smaller.html

My quick hack job for a simple table with a few rows only (assume all rows have same text height and this probably only works for some fonts maybe only on Windo):

int rowHeight = ui.tableView_Available->rowHeight(0) *1/2;
for (unsigned int i = 0; i < model->rowCount(); i++)
  ui.tableView_Available->verticalHeader()->resizeSection(i, rowHeight);
answered 2011-01-14T20:33:19.443

Your Answer