Unsolved Why does the vertical scrollbar handle jump up abruptly , while scrolling down to 256'th rows ?
-
There is a QTableView in my Qt GUI Application, which displays data , read from sqlite database(the sqlite database has 2000 rows).The view has to show 7 rows at a time. while scrolling down using down arrow button, if the no. of rows crossed to 255, the handle jumps up suddenly. I am using QSqlRelationalTableModel to read data from sqlite database.
-
@Sudo007
are you using custom widgets?
If so please show the code...otherwise this is just guessing -
Qt models support an optional "infinite scroll" behavior via canFetchMore and fetchMore.
This is an optimization so that if your model has say 100000 rows Qt doesn't try to load them all at once.
The way it works is the model loads only some arbitrary number of rows (256 by default) and returnstrue
fromcanFetchMore
. When you scroll near the bottom edge the view callsfetchMore
on the model and another batch is loaded. This happens until you get to the actual last row at which point the model will returnfalse
fromcanFetchMore
. Every time another batch is loaded the scrollbar is adjusted to reflect the number of existing items and current position.QSqlRelationalTableModel
is one of the models implementing "infinite scroll". -
@raven-worx
Hi
i am not using custom widget and i forgot to mention that my Qt version is Qt 4.8.5.
Please find the below code-snippet:QTableView *m_tableView = new QTableView (this);
QSqlRelationalTableModel *model = new QSqlRelationalTableModel ;
model->setTable("myTable");
model->select();
m_tableView ->setModel(model); -
@Chris-Kawa
Hi
i am developing my Qt application using Qt 4.8.5.
Is its possible to increase the no of loaded rows to 2000 from 256?
Is there any documentation saying the model loads 256 rows by default.I am using the following code-snippet :
QTableView *m_tableView = new QTableView (this);
QSqlRelationalTableModel *model = new QSqlRelationalTableModel ;
model->setTable("myTable");
model->select();
m_tableView ->setModel(model); -
@Sudo007
the value of 255 is hardcoded in the sources.
Also read the docs of QSqlQueryModel::fetchMore()
Unfortunately you wont be able to achieve this with SQLite databases unless you recompile Qt and increase this value.