In previous chapters, we managed to always write code without ever relying on threads. It is time to face the beast and truly understand how threading works in Qt. In this chapter, you will develop a multithreaded application that displays a Mandelbrot fractal. It is a heavy computational process that will bring tears to your CPU cores.
In the example project, the user can see the Mandelbrot fractal, zoom in the picture, and pan around to discover the magic of fractals.
The chapter covers the following topics:
Deep understanding of the
QThread
frameworkOverview of all the available threading technologies in Qt
Using a
QThreadPool
class to dispatch jobs and aggregate the resultsHow to synchronize threads and minimize sharing states
Low-level drawing to optimize the performances
Common threading pitfalls and challenges