Update model from thread
-
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? -
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 -
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 ?