Implement asynchronous QAbstractItemModel
-
I am implementing an QAbstractItemModel which fetches data asynchronously over a slow connection. From what I read the methods in QAbstractItemModel should return a response immediately, which can be overwritten later. So I built a simple QAbstractItemModel overriding only rowcount and data.
My algorithm is:
- Upon rowCount() called return cached value or 0 if never fetched before
- Fetch rowCount from remote slow database
- Upon receipt of response issue beginInsertRows and endInsertRows
That works, but the data method is never called. So my 3 items in the view are empty. Why is 'data' not called for each item?
-
I am implementing an QAbstractItemModel which fetches data asynchronously over a slow connection. From what I read the methods in QAbstractItemModel should return a response immediately, which can be overwritten later. So I built a simple QAbstractItemModel overriding only rowcount and data.
My algorithm is:
- Upon rowCount() called return cached value or 0 if never fetched before
- Fetch rowCount from remote slow database
- Upon receipt of response issue beginInsertRows and endInsertRows
That works, but the data method is never called. So my 3 items in the view are empty. Why is 'data' not called for each item?
-
Closing this one