Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Update model from thread
Forum Updated to NodeBB v4.3 + New Features

Update model from thread

Scheduled Pinned Locked Moved General and Desktop
3 Posts 2 Posters 1.1k Views 1 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.
  • E Offline
    E Offline
    error09
    wrote on last edited by
    #1

    Hi,

    I created a model similar to QFileSystemModel.
    My application receives "files structure" over the network and puts them in the model. (i have to check if current file already exist in model, and if not, i put them in model)

    I would like now to move the model updates to thread, how can i do this?
    Can i make my model thread-safe and pass pointer to thread or should i use only signal/slot communication with thread?

    1 Reply Last reply
    0
    • JeroentjehomeJ Offline
      JeroentjehomeJ Offline
      Jeroentjehome
      wrote on last edited by
      #2

      Hi,
      For thread-safe operations it's the most easiest way to use the signal/slot solution. In your case however it looks like two threads will share the same data (model/gui and tcp thread?) Then a mutex should be used to share the same memory.
      Or try this:"QSharedMemory":http://qt-project.org/doc/qt-5/QSharedMemory.html#details

      Greetz, Jeroen

      1 Reply Last reply
      0
      • E Offline
        E Offline
        error09
        wrote on last edited by
        #3

        My model will be shared between the threads, because i can receive lot of "file structures".
        so even if i use slots a have to synchronize access to my model between main thread and other threads ?

        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