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. QList<*QObject> property thread safety
Forum Updated to NodeBB v4.3 + New Features

QList<*QObject> property thread safety

Scheduled Pinned Locked Moved Unsolved QML and Qt Quick
3 Posts 3 Posters 477 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.
  • P Offline
    P Offline
    poncho524
    wrote on last edited by
    #1

    if one thread is updating a QList<*QObjects> and the qml thread is using this as a ListView model, how can thread safety be guarenteed?

    jeremy_kJ 1 Reply Last reply
    0
    • sierdzioS Offline
      sierdzioS Offline
      sierdzio
      Moderators
      wrote on last edited by
      #2

      They work on separate copies of the list.

      (Z(:^

      1 Reply Last reply
      0
      • P poncho524

        if one thread is updating a QList<*QObjects> and the qml thread is using this as a ListView model, how can thread safety be guarenteed?

        jeremy_kJ Online
        jeremy_kJ Online
        jeremy_k
        wrote on last edited by
        #3

        @poncho524 said in QList<*QObject> property thread safety:

        if one thread is updating a QList<*QObjects> and the qml thread is using this as a ListView model, how can thread safety be guarenteed?

        There's a multithreading list model example that covers updating a ListModel outside of the gui thread.

        The Qt containers are documented as thread-safe only if the container is read-only. Otherwise, mutual exclusion is necessary to protect accesses.

        QObject also isn't thread safe. If they are allocated in a worker thread, don't forget to QObject::moveToThread() before the gui thread has an opportunity for access. Once that is done, the worker thread can't safely access the object.

        Asking a question about code? http://eel.is/iso-c++/testcase/

        1 Reply Last reply
        3

        • Login

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