I have a simulation running on a std::thread that has regular sleeping periods and at the end of each period QWidget::update() is called on my custom QGraphicsObject. It works most of the time, sometimes calculating 100k iterations on a 1024^2 grid, but sometimes from a point QGraphicsView doesn't update itself anymore. I suspect some multi-threaded communication problem.
I've read that Cocos2d-x for example can't handle concurrent calls in it's API excluding some property modification. I haven't found information about thread safety on Qt docs, some people here said Qt Widgets are not thread-safe. Actually QWidget::update() is a public slot, so shall I try converting all direct function calls to update() to emit signals? I would like to do my threading in pure c++, what are constraints of this when working with Qt?
(I'll open a new question specifically about the problem if using std::thread like this is supposed to be safe)
In Qt it is very important that methods of GUI objects are only called in the GUI (typically main) thread.
Signals and slots in Qt however do work over thread boundaries as long as the receiver thread (slot) is running an event loop (as the Qt thread obviously does). There is no other requirement on this thread or the signaller's thread. If you send a signal from a different thread, Qt automatically enqueues it into the receiver thread's event queue.
This can also be made explicit when setting up the signal/slot connection by passing the right connection type parameter. See the explanation of connection types in Qt doc.
So the answer is yes, you cannot reliably call any widget methods from other threads and yes, the signal/slots mechanism is a proper means of ensuring thread-safety when triggering GUI actions from a worker thread.