[SOLVED] Fetch entire result set at once with QSqlRelationalTableModel + QTableView


I have a QTableView with a QSqlRelationalTableModel as the model. Essentially:

QSqlRelationalTableModel *theModel = ...;
QTableView *theView = ...;


It seems, though, that select() doesn’t load the entire result set at once. Rather, it fetches a portion, and then fetches more as I scroll towards the bottom of the table view.

Usually this is what I’d want to happen, but for this particular application I’d like to fetch the entire result set (instead of a portion at a time) so that the view is immediately populated with the full set without any scrolling or other interaction required.

Is there a way to make this happen?

That is, is there a way to get the view/model to grab the complete result set right off the bat?

I’m using Qt 5.15.2, and currently using the QSQLITE driver.


This is properly described in the documentation: To force fetching of the entire result set, you can use the following:

while (myModel->canFetchMore())

Answered By – chehrlic

Answer Checked By – Katrina (BugsFixing Volunteer)

Leave a Reply

Your email address will not be published. Required fields are marked *