Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

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:

    1. Upon rowCount() called return cached value or 0 if never fetched before
    2. Fetch rowCount from remote slow database
    3. 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?



  • @ocgltd if you put together a few lines of representative code, you're much more likely to get answers here.

    Also: are you sure you wanted to post this in the QML forum?


  • Lifetime Qt Champion

    Duplicate here

    Closing this one


Log in to reply