Accessing QObject property from a non QObject subclass in another thread
-
I have use case where I want to read properties of a QObject from a non QObject subclass (so no signals and slots) that is in another thread (non Qt thread).
I got the instance of the QObject form the class by using its object name property and using the find Child class from the root object.
Is it safe to do so? Are these methods reentrant? -
@glamis When a function is thread safe or reentrant then the documentation will tell you. Otherwise you have to assume it is not.
-
@Christian-Ehrlicher thanks for your response, in that case is the right way do so is to call the non thread safe methods in the context of the callee and use a QConcurrent run in the caller side?
-
I would do so, yes. Even though I would not expect a threading problem with qFindChild as long as the object tree is not changing but one never knows.