Hello!
I'm creating a model, connected with a db-table from SQlite and show it using tableView. Here is my code:
Qt Code:
  1. model->setTable("publications");
  2. model->setRelation(6, QSqlRelation("pub_types", "id", "type"));
  3. model->setEditStrategy(QSqlTableModel::OnFieldChange);
  4. model->select();
  5. while(model->canFetchMore())
  6. model->fetchMore();
  7. ui->tableView_pub->setModel(model);
  8. ui->tableView_pub->setFocus();
  9. ui->tableView_pub->selectRow(model->rowCount()-1);
To copy to clipboard, switch view to plain text mode 
QSqlRelationalTableModel class is implemented with a so-called "lazy population". When i'm working with table, it loads only first 255 rows from database, and the rest only after scrolling. I don't need it, I want to load all data at once (there is enough memory and database is not too large)
Everywhere I can, I use this code: "while(model->canFetchMore()) model->fetchMore();". It works just fine, tableview always loads all data at once.
However, I also need to use OnFieldChange editing strategy. Herewith, when user finishes editing of a cell from a row with number more than 255, table in database changes, and tableview load data again. But, this time I can't insert my "while(model->canFetchMore()) model->fetchMore();" anywhere, because it is hidden somewhere inside the class. As a result, after editing tableView jumps to 255-th row. This is very inconvinient.
My question is, how to change this situation? How to change methods of QSqlRelationalTableModel to load all data at once, or somehow increase this 255-rows limit?