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 a la dataChanged(..) handler. I can reproduce the issue by calling setText("xxxxx")
repeatedly in a for 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? If I understand correctly, this is related to queued connection and QStandardItemModel
is not thread safe? How to get around this issue?
Thanks!
QStandardItemModel
is part of the QtGui Library, iirc all classes in there are considered not threadsafe. You should be ok if you move the actual setting of the data into the GUI thread. You can do that pretty easily by using a queued signal from you network thread.