Running a separate process or thread in Qt


I'm writing my first proper useful piece of software. Part of it will involve the user viewing an image, and choosing to accept or reject it. Doing this will cause the image to be saved to an accepted or rejected folder, and possibly rotated and/or resized.

At the moment, my rotate/resize/save operation is pausing execution of my program, but I'd like it to happen in the background so the next image is displayed instantly.

Is the only way to do this in Qt to process the image in a separate thread, or is there another way? I'm still getting my head round C++ and Qt, so I don't want to confuse myself by diving into a new field!

5/28/2009 10:10:59 PM

Accepted Answer

Qt has thread support. You might find this example application interesting since it's somewhat similar to what you describe.

Also, here is the full Qt thread documentation.

2/13/2013 7:03:56 AM

these kind of tasks are perfectly suited for threads. still, you should first do a 'normal' function that does it, and when it works add a thread that reads a queue and calls the same processing function.

Qt has a lot of tools to help you on this, mainly the fact that most of the containers are thread-safe, and also a couple of threading algorithms (like map-reduce). still, first try it synchronously.

Licensed under: CC-BY-SA with attribution
Not affiliated with: Stack Overflow