Unsolved incremental loading in table view without canFetchMore() and fetchMore()
-
i'm using a library which is based on qt.
the library has a table model/view implementation.
i need incremental populating for my table. however they do not havecanFetchMore()
andfetchMore()
implemented.in what ways can i implement lazy loading anyways?
one option i could think of was this:
i have the following variables:chunkRows
- i want to retrieve this many rows at a time,m_currRowCount
- the number of row currently loaded- set initial row count = chunkRows
- in
data()
i do this check:
if (index.row() + chunkRows >= m_currRowCount) m_currRowCount += chunkRows; ... return the data;
this approach doesn't work. in my table i get only the first
chunkRows
items.please help :(
-
Hi,
What do you mean by "they do not have" ?
What kind of model are you using ? -
@SGaist
i mean if those methods were implemented, i could make use of those for implementing lazy loading.
the model is derived fromQAbstractTableModel
, this is a part ofdata()
, wherem_pModel
is a vector of vectors:QVariant TableModel::data(const QModelIndex& index, int role) const { int nRow = index.row(); int nCol = index.column(); if (nRow < 0 || nRow >= m_pModel->getRowCount() || nCol < 0 || nCol >= m_pModel->getColumnCount()) return QVariant(); if (role == Qt::DisplayRole) { QString sStr; m_pModel->getText(nRow, nCol, sStr); return sStr; } ....
i tried to increase the row count in
m_pModel->getRowCount()
implementation, but i guess the problem why that idea doesn't work is that the actualdata
isn't called for those increased rows, therefore,m_pModel->getText()
isn't called either.