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. ListModel sync() Function Throwing Out-Of-Range Errors
QtWS25 Last Chance

ListModel sync() Function Throwing Out-Of-Range Errors

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
qmlworkerscriptsynclistmodel
2 Posts 2 Posters 996 Views
  • 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.
  • L Offline
    L Offline
    larkei15
    wrote on 24 Aug 2018, 19:07 last edited by
    #1

    Hello all,

    In my QML app, I have a WorkerScript that I'm using to fill a ListModel with data from a database or file. This ListModel then provides the data for a Repeater to display it in a Column. As far as I can tell, it is filling properly, but I'm getting tons of errors saying that I'm calling set() on the ListModel when it is synced at the end of the WorkerScript. I am able to get rid of the error messages by syncing after every append() that I call in the script, but that is uselessly inefficient.

    Again, it seems that the data is being loaded properly, but the messages still keep popping up in the console. Perhaps it is a bug.

    If anyone can see what I could be doing wrong, help would be appreciated.

    Thanks,
    Keith

    D 1 Reply Last reply 25 Aug 2018, 02:54
    0
    • L larkei15
      24 Aug 2018, 19:07

      Hello all,

      In my QML app, I have a WorkerScript that I'm using to fill a ListModel with data from a database or file. This ListModel then provides the data for a Repeater to display it in a Column. As far as I can tell, it is filling properly, but I'm getting tons of errors saying that I'm calling set() on the ListModel when it is synced at the end of the WorkerScript. I am able to get rid of the error messages by syncing after every append() that I call in the script, but that is uselessly inefficient.

      Again, it seems that the data is being loaded properly, but the messages still keep popping up in the console. Perhaps it is a bug.

      If anyone can see what I could be doing wrong, help would be appreciated.

      Thanks,
      Keith

      D Offline
      D Offline
      Diracsbracket
      wrote on 25 Aug 2018, 02:54 last edited by Diracsbracket
      #2

      Hi @larkei15
      I don't think using a Repeater for dynamically changing models is the best approach.

      From the Cadaques book:
      https://qmlbook.github.io/ch06/index.html

      For static models, a Repeater can be used as the view. It is easy to combine it with a positioner such as Row, Column, Grid or Flow to build user interface parts. For dynamic or large data models, a view such as ListView or GridView are more appropriate. These create delegate instances on the fly as they are needed, reducing the number of elements live in the scene at once.

      And from the QML doc:
      http://doc.qt.io/qt-5/qml-qtquick-repeater.html

      Considerations when using Repeater
      The Repeater type creates all of its delegate items when the repeater is first created. This can be inefficient if there are a large number of delegate items and not all of the items are required to be visible at the same time. If this is the case, consider using other view types like ListView (which only creates delegate items when they are scrolled into view) or use the Dynamic Object Creation methods to create items as they are required.

      I wager your syncing problems are due to that...

      Is there any reason why you are choosing the Column + Repeater approach over the ListView approach?

      1 Reply Last reply
      1

      2/2

      25 Aug 2018, 02:54

      • Login

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