PDA

View Full Version : Modifying QStandardItemModel from non-UI QThread?



m3rlinez
11th December 2010, 12:50
Hi,

I have Qt4 app which binds QStandardItemModel to the QListView and have the model updated from background/non-UI thread.

Sometimes, when the QStandardItem's setText(..) method is called very repeatedly from the non-UI thread, the application will crash at data_changed(..) handler. I can reproduce the issue by calling setText("xxxxx") repeatedly in a loop. In my app, the data is read from network hence I update the model in separate, non-UI thread.

Is this a common pb? Having search the forums but couldn't find sth similar ...

Thanks!

wysota
11th December 2010, 13:50
You cannot directly interact with QStandardItemModel from a worker thread.

m3rlinez
11th December 2010, 17:56
@wysota Thanks for confirming this! Looks like I will have to go with slot + signal to update QStandardItemModel from GUI thread .. Just imagine it would be nice if we have a thread-safe version (:

wysota
11th December 2010, 18:02
Just imagine it would be nice if we have a thread-safe version (:
The whole Qt would probably become much much slower then.