Hi, Some how I could able to read and show the data in view with lazy population, But has below problems.
I have implemented canFetchData & featchData functions
I am using proxy model too, setting below TreeModel as a sourse model;
bool TreeModel
::canFetchMore(const QModelIndex &parent
) const {
qint64 totalRowCount = sql_reader->getTotalRowsNumber(); //returns Total no.of rows
if(totalRowCount > lastreadRowNumber) //I am storing Last read Row
{
return true; //still not reached end of the table
}
return false;
}
bool TreeModel::canFetchMore(const QModelIndex &parent ) const
{
qint64 totalRowCount = sql_reader->getTotalRowsNumber(); //returns Total no.of rows
if(totalRowCount > lastreadRowNumber) //I am storing Last read Row
{
return true; //still not reached end of the table
}
return false;
}
To copy to clipboard, switch view to plain text mode
void TreeModel::fetchMore(const QModelIndex& parent)
{
qint64 totalRows = sql_reader->getRowNumber();
int readBulk = 1000; //reading 1000 rows on demand
if( totalRows < ( readBulk + lastreadRowNumber) )
{
readRows = totalRows - lastreadRowNumber; //adjustment for last few rows
}
beginInsertRows
(QModelIndex(), m_lastreadRowIndex, m_lastreadRowIndex
+readRows
-1);
emit fetchMoreData(lastreadRowNumber, m_lastreadRowIndex+readRows);
//by emiting signal, I am getting data from sql database of range above
//with that data I am forming My Parent and child relationship
//and saving lastreadRowNumber
endInsertRows();
}
void TreeModel::fetchMore(const QModelIndex& parent)
{
qint64 totalRows = sql_reader->getRowNumber();
int readBulk = 1000; //reading 1000 rows on demand
if( totalRows < ( readBulk + lastreadRowNumber) )
{
readRows = totalRows - lastreadRowNumber; //adjustment for last few rows
}
beginInsertRows(QModelIndex(), m_lastreadRowIndex, m_lastreadRowIndex+readRows-1);
emit fetchMoreData(lastreadRowNumber, m_lastreadRowIndex+readRows);
//by emiting signal, I am getting data from sql database of range above
//with that data I am forming My Parent and child relationship
//and saving lastreadRowNumber
endInsertRows();
}
To copy to clipboard, switch view to plain text mode
//With this I am able to load all the data, But when loading a data, I am getting below messages on console
QSortFilterProxyModel: invalid inserted rows reported by source model
//When I try to move and exapand the tree i am able to do it for 2/3 times then tool suddnley geting crashed by showing
Error message
QSortFilterProxyModel: invalid inserted rows reported by source model
When I tried: beginInsertRows(parent, m_lastreadRowIndex, m_lastreadRowIndex+readRows-1);
I got below error and tool got crashed
QSortFilterProxyModel: invalid inserted rows reported by source model
QSortFilterProxyModel: index from wrong model passed to mapFromSource
QSortFilterProxyModel: index from wrong model passed to mapFromSource
QSortFilterProxyModel: index from wrong model passed to mapFromSource
Could you please let me know, what is the wrong thing I am doing here ?
Bookmarks