Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
Question regarding background threads to process a QImage
PPNN last edited by
I'd appreciate your advice re the design of an application part that requires the repeated processing of a large QImage depending on some GUI elements. The idea is that the resulting QImage "tracks" settings made by the user (input data is from another QImage).
My original idea was to have a number of worker threads spawned to process groups of scanlines of the QImage. In case the user re-adjusts the GUI settings, the execution of these threads would be stopped, and new threads started based on the new GUI settings. Once all threads complete (without being interrupted by the user changing the settings further), the QImage would then be copied to a QPixmap that is part of a QGraphicsScene.
My questions now are:
I read that QObjects are not thread-safe. Does that mean that I cannot have several parallel threads work on sections (scanlines) of a QImage? Would there also be a conflict between the main GUI thread (where this QImage was created) and the worker threads? If yes, is there a way to solve this without copying large chunks of data to the threads and then back again?
What would the best way be to wait for the successful completion of these worker threads without introducing a blocking condition in the main applications event loop?
Thanks for your advice