Your question is very broad. Please find some alternatives that may be useful to you:
- If you want to use the signal / slot mechanism and execute your slot in the context of the stream, you can use the moveToThread method to move the object into the stream (or create it directly in the QThread launch method) and execute your slot in this stream context. But Qt Docs says that
An object cannot be moved if it has an ancestor.
Since your object is a widget, I assume it will have a parent.
Thus, it is unlikely that this method will be useful to you.
Another alternative is to use QtConcurrent :: run (). This allows another thread to execute. However, in this way you cannot use the signal / slot mechanism. Since you declared your method as a slot. I suggested that you want to use this mechanism. If you are not caring , then this method will be useful to you.
Finally, you can subclass QThread in your slot and do whatever you like.
That is all I could think of.
Hope this helps.
OC
source share