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. Suggestions Please : Better way to handle large set of data in QML List view/C++ List model
Forum Updated to NodeBB v4.3 + New Features

Suggestions Please : Better way to handle large set of data in QML List view/C++ List model

Scheduled Pinned Locked Moved QML and Qt Quick
2 Posts 1 Posters 1.4k Views 2 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.
  • A Offline
    A Offline
    ashwasimha
    wrote on last edited by
    #1

    Hello All,

    In my project, I need to display list of some data using QML List view.And, the QT version I am using is QT 5.0.2. Since, scroll bar view is not available in this version of Qt, I managed to implement it by following this example.

    Now, the data source is an other component which has provided C++ APIs to request for range of data. And the number of elements in the data set can be huge (in terms of tens of thousands).

    I have followed below steps to achieve my requirements :

    1. I have a created a C++ class that inherits from QAbstractListModel and I have overridden rowCount, data, canfetchmore and fetch more functions.
    2. And in the QML, I have referred the instance C++ as model.
    3. Whenever fetchmore() function is called, I am requesting next set of data using C++ APIs that are provided by another component and appending the same to my list model.

    So far, it is good. But I need few clarifications -

    1. If I keep appending the data to my list model,then I will end up storing thousands of elements in the list (I don't want to do that). I want to limit the number of elements in the list and use it as a ring buffer. Is this possible?
    2. QModelIndex parameter in fetchmore is received as invalid Index. Why?
    3. Assume a case : alphabets are mentioned on scrollbar, and when user selects Y on scrollbar, I should fetch elements that starts with Y. Here, I can fetch the data from my external component and reset the list model with new data. But, if I do that,then my list will start with Y-elements and I will not be able to scroll up to get previous elements. -- Is there any other way to achieve this?
    4. Also, my other component takes considerable time if I ask huge set of data (for example in cases as mentioned in point 3) - Any suggestions to make a better design to handle this case?
    5. Is there any way, other than fetchmore(), to update the model dynamically.

    I have spent good amount of time on google to get answers to my questions and I have successfully FAILED. :(

    Any help appreciated. Thanks in advance.

    1 Reply Last reply
    0
    • A Offline
      A Offline
      ashwasimha
      wrote on last edited by ashwasimha
      #2

      Hi All,

      I have managed to handle it in better way. Please check this post for an answer.

      1 Reply Last reply
      2

      • Login

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