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

What just happened?

Our new project is so simple that all its code is located in the main() function. Let's examine the code. First, we create a QApplication object, as in any Qt Widgets project. Next, we create a scene object and three instances of different item classes. The constructor of each item class accepts an argument that defines the content of the item:

  • The QGraphicsRectItem constructor receives a QRectF object that contains the coordinates of the rectangle
  • The QGraphicsEllipseItem constructor, similarly, receives a QRectF object that defines the bounding rectangle of the circle
  • The QGraphicsSimpleTextItem constructor receives the text to display
QRectF is basically a helpful struct with four fields that allow us to specify four ...

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