O'Reilly logo

Game Programming using Qt 5 Beginner's Guide - Second Edition by Lorenz Haas, Witold Wysota, Pavel Strakhov

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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); ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required