Does QSqlTableModel have a limit of records?
-
Does QSqlTableModel have a limit of records that can be retrieved?
Why am I asking this?
When I retrieve 9305 database records and apply a QSortFilterProxyModel to the QSqlTableModel my search works. However, when I have 9306 database records the search does not work anymore as expected.I can't find any error in the database in the column I am searching. But I'm happy to provide it if someone wants to have a look if they find an error. The database is generated by a python script.
Do you have any idea what the problem could be if there is no limit?
-
@Gabber
There should be no such limit. And certainly not at 9,306!Re-look at your code. You can show it if you wish, but it probably won't help.
Don't forget: your
QSqlTableModel
should have been filled viawhile (canFetchMore()) fetchMore();
If you have not done this your in-memory records to search may be incomplete. -
@JonB
Thank you very much. You are a hero!@JonB said in Does QSqlTableModel have a limit of records?:
while (canFetchMore()) fetchMore();
That solved my problem. Now my code looks like this:
QSqlTableModel *DatabaseManager::fungusTable() const { QSqlTableModel *model = new QSqlTableModel; model->setTable("Pilze"); model->setSort(1, Qt::AscendingOrder); model->setEditStrategy(QSqlTableModel::OnManualSubmit); model->select(); while (model->canFetchMore()) { model->fetchMore(); } return model; }
Thanks for your help!
-
@Gabber
Yup.QSortFilterProxyModel
is an in-memory-proxy-only, it passes neither the sort nor the filter to theQSqlTableModel
(for execution at the SQL side) but rather just sorts/filters what is already in the underlying in-memory model.OOI, what version of Qt are you using? Qt6?? Until now/so far as I know
QSqlTableModel
has always had a value of 256 hard-coded for how many rows it fetches before you have tofetchMore()
. Yours looks like that has been increased to 9,306?