hickscorp
17th November 2011, 17:49
Hello everybody,
i'm facing a rather odd bug using a QTableView linked to a custom derived QSqlTableModel.
Basically, my table view displays data from a SQLite backend, itself being accessed via a very simple QSqlTableView derived model.
However, random behavior happens. For instance, if i press Ctrl+A to select everything in the table, only the first 256 rows gets selected.
Then if i play with the GUI and scroll up / down, i'm then able to manually select the remaining rows (39 of them, i have 295 records in my table).
The other very annoying bug is that if i select any row after the 256th, i can't change it's value. For instance, i have buttons to allow checking / unchecking several rows at the same time. This button works only on the first 256th rows displayed by the table:
void REA::WgtDocumentTypesManager::on_btnSampleImagesCh eck_clicked () {
while (_siModel->canFetchMore()) _siModel->fetchMore();
QModelIndexList rows = ui.tblVwSampleImages->selectionModel()->selectedRows();
foreach (QModelIndex const &i, rows)
_siModel->setData (_siModel->index(i.row(), SampleImagesModel::Training), 1);
}
What can i possibly be doing wrong here?
i tried putting some [ while (canFetchMore()) fetchMore(); ] ish code all over, nothing changes.
Thanks a lot,
Pierre.
Added after 32 minutes:
i temporarilly solved my problem by doing this in my QSqlTableModel derived model:
bool REA::SampleImagesModel::select () {
bool toRet = QSqlTableModel::select();
while (canFetchMore()) fetchMore();
return toRet;
}
Which means that there is probably a bug in the implementation of QTableView.
Any idea on how to properly solve this please?
i'm facing a rather odd bug using a QTableView linked to a custom derived QSqlTableModel.
Basically, my table view displays data from a SQLite backend, itself being accessed via a very simple QSqlTableView derived model.
However, random behavior happens. For instance, if i press Ctrl+A to select everything in the table, only the first 256 rows gets selected.
Then if i play with the GUI and scroll up / down, i'm then able to manually select the remaining rows (39 of them, i have 295 records in my table).
The other very annoying bug is that if i select any row after the 256th, i can't change it's value. For instance, i have buttons to allow checking / unchecking several rows at the same time. This button works only on the first 256th rows displayed by the table:
void REA::WgtDocumentTypesManager::on_btnSampleImagesCh eck_clicked () {
while (_siModel->canFetchMore()) _siModel->fetchMore();
QModelIndexList rows = ui.tblVwSampleImages->selectionModel()->selectedRows();
foreach (QModelIndex const &i, rows)
_siModel->setData (_siModel->index(i.row(), SampleImagesModel::Training), 1);
}
What can i possibly be doing wrong here?
i tried putting some [ while (canFetchMore()) fetchMore(); ] ish code all over, nothing changes.
Thanks a lot,
Pierre.
Added after 32 minutes:
i temporarilly solved my problem by doing this in my QSqlTableModel derived model:
bool REA::SampleImagesModel::select () {
bool toRet = QSqlTableModel::select();
while (canFetchMore()) fetchMore();
return toRet;
}
Which means that there is probably a bug in the implementation of QTableView.
Any idea on how to properly solve this please?