How to do it...

Let's start our fun project through the following steps:

  1. Again, we start by creating a new Qt Widgets Application project and removing the tool bar and status bar. We will keep the menu bar this time.
  2. After that, set up the menu bar like so:
  1. We will leave the menu bar as it is for the moment, so let's proceed to the mainwindow.h file. First, include the following header files, as they are required for the project:
#include <QPainter>#include <QMouseEvent>#include <QFileDialog>
  1. Next, declare the variables that we'll be using for this project, like so:
private:    Ui::MainWindow *ui;    QImage image;    bool drawing; QPoint lastPoint; ...

Get Qt5 C++ GUI Programming Cookbook - Second Edition 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.