Time for action – Creating a sine graph project

Use Qt Creator to create a new Qt Widgets project and name it sine_graph. On the Class Information page of the wizard, select QWidget as the base class and input View as the class name. Uncheck the Generate form checkbox and finish the wizard.

We want the View class to be the graphics view, so you need to change the base class to QGraphicsView (the wizard doesn't suggest such an option). For this, edit the class declaration to look like class View : public QGraphicsView ... and the constructor implementation to look like View::View(QWidget *parent) : QGraphicsView(parent) ....

Next, edit the View constructor to enable anti-aliasing and set a new graphics scene for our view:

setRenderHint(QPainter::Antialiasing); ...

Get Game Programming using Qt 5 Beginner's Guide - 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.