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. Best way to populate/update/delete info from a list(ListView/ListModel) from C++

Best way to populate/update/delete info from a list(ListView/ListModel) from C++

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

    Hi everyone.
    I'm looking for a best way to populate, update a certain element or delete it from a list(LiswView) from C++
    The list will be updated from multiple threads.

    The best way I found so far is to create a threaded ListModel like this one: "Threaded ListModel Example":http://doc.qt.nokia.com/4.7/declarative-threading-threadedlistmodel.html

    then I will access javascript function from C++ using "QMetaObject::invokeMethod":http://doc.qt.nokia.com/4.7/qml-extending-types.html#adding-new-methods

    Do you think my method is safe in terms of performance because a lot of ListModel elements will be updated in the same time. Also the ListModel will have around 200-300 elements.

    Do you think of a better method to achieve this?

    Also an informative question , how do I send this parameter from c++ using invokeMethod?
    @var msg = {'action': 'appendCurrentTime', 'model': listModel};@

    1 Reply Last reply
    0
    • M Offline
      M Offline
      mbrasser
      wrote on last edited by
      #2

      Hi,

      If the model is primarily going to be manipulated from C++, you could also consider writing a custom QAbstractListModel subclass (you'll need to handle the threading yourself though)

      Regards,
      Michael

      1 Reply Last reply
      0

      • Login

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