You can't execute GUI code from any thread except the main one. If you need to send information from a worker thread to the main thread, then use signals and slots. If the sender and receiver of a signal / slot connection live in different threads, the sender's signal will automatically be queued to be processed as an event by the receiver's event queue. This is thread safe.But how can I work with the UI of the mainWindow from the MyClient file ??
You can use any parameters in your signal and slot, as long as Qt's metatype system can serialize them into temporary objects while queuing the signal. Most of Qt's built-in data types (like QByteArray or QString) are supported.
So, if you need to have something in your worker thread cause a change to some GUI feature in the main thread, connect a signal from the worker thread instance to a slot in the main thread, and when the worker thread needs to notify the GUI, send the signal. The slot uses whatever data is transferred to update the GUI.
Bookmarks