PDA

View Full Version : QTableView performance issue with vertical header (8 million items)



ednakram
30th March 2018, 23:55
Hi All,
I have a model that has 8 million rows and the data is shown using a QTAbleView. There is a QSortFilterProxyModel to filter the rows.
Problem is that when filtering, leads to the GUI freezing for several minutes (maybe infinitely - even freezes the VNC session itself).

The process shows the following stack trace. It looks like the vertical header is responding to all of the rowsRemoved signals emitted from the proxy model in it's slot - QHeaderViewPrivate::_q_sectionsRemoved

Do note that vertical header itself is hidden but still that doesn't prevent the calculation to happen in the slot QHeaderViewPrivate::_q_sectionsRemoved.

Currently there is no way to remove a vertical header from the QTableView - QTable::setHorizontalHeader returns if passed a nullptr.

Any suggestions of how to deal with this?
(also is there is likelihood of hitting other issues even if this one is resolved given the order of the data?).

Thanks in advance for the help.



Thread 1 (Thread 0x2ad8ac45acc0 (LWP 17625)):
#0 0x00002ad8abae108c in QHeaderView::isSectionHidden(int) const () from /build/Linux64/lib/libQtGui.so.4
#1 0x00002ad8abae2de6 in ?? () from /build/Linux64/lib/libQtGui.so.4
#2 0x00002ad8abae4b08 in ?? () from /build/Linux64/lib/libQtGui.so.4
#3 0x00002ad8abaed76c in QHeaderView::qt_metacall(QMetaObject::Call, int, void**) () from /build/Linux64/lib/libQtGui.so.4
#4 0x00002ad8aa9ec77f in QMetaObject::activate(QObject*, QMetaObject const*, int, void**) () from /build/Linux64/lib/libQtCore.so.4
#5 0x00002ad8aaa31064 in QAbstractItemModel::rowsRemoved(QModelIndex const&, int, int) () from /build/Linux64/lib/libQtCore.so.4
#6 0x00002ad8aa9d6bd7 in QAbstractItemModel::endRemoveRows() () from /build/Linux64/lib/libQtCore.so.4
#7 0x00002ad8abb53be0 in ?? () from /build/Linux64/lib/libQtGui.so.4
#8 0x00002ad8abb54304 in ?? () from /build/Linux64/lib/libQtGui.so.4
#9 0x00002ad8abb547b1 in ?? () from /build/Linux64/lib/libQtGui.so.4
#10 0x00002ad8abb54d51 in QSortFilterProxyModel::invalidateFilter() () from /build/Linux64/lib/libQtGui.so.4
#11 0x000000000103b5fa in ?? ()
#12 0x0000000000b45803 in ?? ()
#13 0x0000000000c02688 in ?? ()

ChristianEhrlicher
31st March 2018, 09:10
The only way I see is to not use QTableView at all and implement something by your own.
And Qt4 is outdated for a long time... maybe it works better with Qt5 (use at least 5.11 since there are some optimizations in 5.11 which were not in 5.9.3)

ednakram
31st March 2018, 09:25
Thanks @ChristianEhrlicher.

Do you know what kind of optimizations - in QHeaderView or model classes?

ChristianEhrlicher
31st March 2018, 10:37
Maybe not on filter invalidation but on sorting there are some things added to not do complete layouting.
I'm not sure but how do you add your items? Maybe adding them in bulk instead one by one is better. But don't know your code.
/edit: maybe it would be good to have a simplified testcase (filled with dummy data) to help you better.