View Full Version : QTableView / QHeaderView performance / Blocking signals to an object

23rd October 2009, 10:49
I have a QTableView with custom modal that has upto 1 million rows, with data being added 10 times a second. Old data is removed if the data ever exceeeds 1 million.

This uses a suprising amount of cpu time considering how simple it is. Using a performance analyser, it seems that the entire tableview is read for every single row addition after the model calls endInsertRows(). In particular, QHeaderView::isSectionHidden and a few other methods are called for every single row, so approx 1 million times for each row added, and this seems to be where most of the cpu usage is.

Also the entire QTableView is repainted after every addition, even when the new data isn't visible and there was no changes to existing data.

Is this normal? And if so, why is QHeaderView being so CPU intensive? Column sizes are set manually so it shouldn't need to read the row data at all ? Can I block QHeaderView from receiving signals whilst I add an item to confirm these findings? It seems not as blockSignals only stops them from being transmitted, not received (and I need the signal to be received by the scrollbar), and eventfilter doesn't handle signals...

5th October 2012, 15:00
Shame no one replied here :(

16th November 2012, 21:41
i face the same behaviour with qt 4.6. Is there any hint how to fix this?

I have a customized qheaderview for my qtableview. The view gets a QSortFilterProxyModel holding a customized AbstractItemModel as sourceModel.

If I add 1000000 million rows to the empty model it works fast. If i now add further lines qt calls (for example) the sizehint of the headerview for each added line. This takes ages...

Is there any explanation/fix.

Thanks for any hint.

PS. updating the qt version is not an option