In this recipe, you will learn to display a 2D graphical image. We assume that you have a graphical image by the name scene.jpg on your machine, and you will learn how it is displayed on the form. The focus of this recipe is to understand how the Graphics View widget is used to display an image.
Displaying a 2D graphical image
How to do it...
The procedure for displaying graphics is very simple. You first need to create an object of QGraphicsScene, which in turn makes use of the QGraphicsView class to show its contents. Graphical items, including images, are then added to the QGraphicsScene class by invoking the addItem method of the QGraphicsScene class. Here are the steps to display a 2D graphical image on the screen:
- ...