Reputation: 325
I have a QTableWidget that can display a huge number of elements (like, 20000 elements). Displaying per se and scrolling up and down works find, however, populating the widget works extremely slowly. I found out that constructing the QVector of elements (strings) that are displayed works very fast, however, inserting the elements into the QTableWidget is very slow.
I need to implement filtration over the elements, so if the user filters half of the elements out with a wildcard, it's still necessary to clean the QTreeWidget and insert 10000 elements back (or hide 10000 elements which is equally slow). Reasonably fast performance is critical here because the user can't wait for several minutes every time he presses a button.
Valgrind doesn't help much as apparently much of the resources are eaten by some implicitly called functions, particularly QHeaderView::sectionSize()
and QHeaderView::isSectionHidden()
Upvotes: 1
Views: 1122
Reputation: 4237
Migrate Your code to model-view pattern.
QStandardItemModel
) and place all Your data there.QTableView
, ensure everything is OKQSortFilterModel
model for fast data-filtering, or you can subclass QProxyModel for more complex filters. Upvotes: 5