1

I have QTableView with a little number of rows and about 10 columns. I set QHeaderView::ResizeToContents resizeMode for verticalHeader(). But it works only for visible rows. For example if the tableView is scrolled to right and some data have been changed, height of rows become smaller. And after tableView has been scrolled back, height of rows remains too small for cells, which were invisible before. I found that reimplementing of sizeHintForRow(int row) can solve the problem. But I can't find a good way to calculate height of cell (including invisible cells) using top level functions...

I could use original QTableView::sizeHintForRow(). I need only change a little part of it. But it calls d->viewOptionsV4(). And in my instance I can only get QStyleOptionViewItemV1. But it's not enough to have this object to calculate correct sizeHint for itemDelegate.

Any idea about the best way to calculate cell height?

Funt
  • 399
  • 8
  • 23

1 Answers1

0

Ok, I have reimplemented QTableView::sizeHintForRow(). Size hint is calculated in the same way as in original method, but for this purpose I had to initialize QStyleOptionViewItemV4 with help of viewOptions() method and additional settings.

Do you have a better solution?

Funt
  • 399
  • 8
  • 23