Displaying the fractal with MandelbrotWidget

Here we are, the Mandelbrot algorithm is done and the multithreading system is ready to compute complex fractals over all your CPU cores. We can now create the widget that will convert all the JobResult to display a pretty picture.

Create a new C++ class called MandelbrotWidget. For this widget, we will handle the painting ourselves. Thus, we do not need any .ui Qt Designer Form file. Let's begin with the MandelbrotWidget.h file:

#include <memory> #include <QWidget> #include <QPoint> #include <QThread> #include <QList> #include "MandelbrotCalculator.h" class QResizeEvent; class MandelbrotWidget : public QWidget { Q_OBJECT public: explicit MandelbrotWidget(QWidget *parent = 0); ~MandelbrotWidget(); ...

Get Mastering Qt 5 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.