Hi,
I have a QTableView based on a QAbstractTableModel and I need to introduce threads into my program, there will be no more than 10 threads and each thread needs to be able to get data from and send data to the QAbstractTableModel subclass.
The way i want to do it is by passing a pointer to the model to each thread, then make simple function calls to the model via the pointer, and make sure everything is properly locked with mutex's. This presents the possible problem though that the GUI thread may try to get data from the model when it is locked by a worker thread and block till its unlocked, will this have a noticeable impact on the QTableView / main GUI thread?
The second approach i have been advised of is to use signals/slots for cross thread communication, im not really sure how this would work for 2 way communication. I can understand i could send a signal from the worker thread to the model and do something, but i would need to get data back as well? Maybe i could pass a pointer to something as a parameter in the signal to be utilized from the model?
Are signals/slots thread safe by default?
I would really appreciate some advice on how i should design this, its phraphs not ideal having worker threads interact directly with a model but I think i will have to, i just need a simple/safe way to do it.
Thanks for any advice,
Jack
Bookmarks