This article , which details the โproperโ use of QThread, details
By the way, it is very important to note that you should never allocate heap objects (using a new one) in the constructor of the QObject class, since this allocation is then performed in the main thread, and not in a new QThread instance, which means that the newly created object then belongs to the main thread , not an instance of QThread. This will make your code work. Instead, allocate such resources in the main functional slot, for example process (), in which case, when called, the object will be in a new instance of the stream and, therefore, it will own the resource.
I understand the first part that the allocation of heap objects (and therefore the start of the constructor) occurs in the thread that created the QObject. Only after that does he switch to QThread with QThread :: moveToThread.
However, I do not quite understand the mentioned property problem, in particular
means that the newly created object then belongs to the main thread
This, of course, does not mean standard ownership of resources, because in Qt this is easily controlled by the parent-children mechanism.
Does this mean that the main memory management mechanisms are multithreading (or QThread, although this is just a shell for implementing OS threads, as far as I know)? As in the fact that for each thread where its resources are stored, there is a different "memory segment / cache"?
If so, I could see the problem, but I cannot find a complete answer or explanation. Thanks!