PDA

View Full Version : TableView resizeColumnsToContents Slow on large sets of data.



snydesc
28th June 2012, 22:53
I have a table with about 8000 rows and 10 columns. I noticed doing a resizeColumnsToContents is really slow. To speed this up I was going to implement my own that will take the max of the first 25 cells in each column and use that as the column width. Each Cell uses a custom delegate so I want to use the delegate's sizeHint for each cell. Calling sizeHintForIndex( QModelIndex ) does not seem to return the delegate's sizeHint. How can I get the delegate's sizeHint for each cell?

wysota
29th June 2012, 00:05
QAbstractItemDelegate::sizeHint()

snydesc
29th June 2012, 15:11
shouldn't sizeHintForIndex() call that for me? Maybe I am missing something here but it seems like poor implementation to provide a function that returns a sizeHint that makes no sense.

What should I use for QStyleOptionViewItem ? The TableView or Delegate do not appear to have a getQStyleOptionViewItem function (that I can find).

wysota
30th June 2012, 06:15
shouldn't sizeHintForIndex() call that for me?
Maybe it does but it also does a bunch of other stuff. You asked for a method "returning the delegate's size hint" -- it's called sizeHint().


Maybe I am missing something here but it seems like poor implementation to provide a function that returns a sizeHint that makes no sense.
I don't understand what you mean.


What should I use for QStyleOptionViewItem ?
It depends on what you want to get a size hint for.

snydesc
2nd July 2012, 19:22
I would have thought that TableView->sizeHintForIndex() returns the sizeHint of the delegate used for that cell. It does not make sense that it would return a different sizeHint since the table uses the delegate's sizeHint to make the cell the correct size.

wysota
2nd July 2012, 20:49
I would have thought that TableView->sizeHintForIndex() returns the sizeHint of the delegate used for that cell.
The delegate is only a part of the size calculation aspect.


It does not make sense that it would return a different sizeHint since the table uses the delegate's sizeHint to make the cell the correct size.

Sure it does. What if you drag the table header with the mouse increasing the column/row size? Should the sizeHint still be what the delegate reports?