Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. QML and Qt Quick
  4. Implement asynchronous QAbstractItemModel
Qt 6.11 is out! See what's new in the release blog

Implement asynchronous QAbstractItemModel

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
3 Posts 3 Posters 634 Views 3 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • ocgltdO Offline
    ocgltdO Offline
    ocgltd
    wrote on last edited by
    #1

    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?

    mzimmersM 1 Reply Last reply
    0
    • ocgltdO ocgltd

      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?

      mzimmersM Offline
      mzimmersM Offline
      mzimmers
      wrote on last edited by
      #2

      @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?

      1 Reply Last reply
      1
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Duplicate here

        Closing this one

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        1

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved