Implementing charts and graphs

Qt makes drawing different types of diagrams easy by putting the complex drawing algorithms behind different abstraction layers, and providing us with a set of classes and functions that can be used to easily create these diagrams without knowing how the drawing algorithm works behind the scenes. These classes and functions are all included in the chart module that comes together with Qt.

Let's create a new Qt Widgets Application project and try to create our first chart in Qt.

After you have created the new project, open up the project file (.pro) and add the charts module to your project, like so:

QT += core gui charts 

Then, open up mainwindow.h and add the following to include the header files that are required ...

Get Hands-On GUI Programming with C++ and Qt5 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.