PDA

View Full Version : Slow navigating around a QTableView



pwaldron
8th March 2011, 19:24
I have a QSqlTableModel that faces an SQLITE database with about 18000 rows. The model supports a QTableView that displays the data in a tabbed view.

The view populates and displays quickly, but it takes forever (i.e., several seconds) to switch away from the tab to another. Switching back to display the big table is very fast.

The model is populated using the following code


setTable("TDList");
select();
while (canFetchMore())
fetchMore();


The strange thing is that when I remove the while loop, navigation through the tabs is lightning fast. I thought initially it was because model isn't pulling all the rows from the database during the select step(), but even when I manually scroll around the view and force it to fully download all the data redrawing is extremely fast.

I could understand if the table was taking a long time to display (lots of redraws), but that doesn't explain why it takes a long time to shift away from the table to a new tab.

What is it about the fetchMore() loop that is slowing everything down?