The QPainter Class

Understand how our GUI applications use the QPainter class.

Using the QPainter class

You will likely use the QPainter class whenever you need to draw something in PyQt. Simple points and lines, complicated forms, text, and pixmaps can all be drawn using the methods provided by QPainter. In earlier chapters, we looked at pixmaps in applications where we were required to display images. You can alter several QPainter parameters, including rendering quality and the painter's coordinate system. Drawing can be done on a paint device, which are two-dimensional objects made from various PyQt classes and on which QPainter can be used to paint.

Firstly, we start by importing the required modules.

Get hands-on with 1400+ tech skills courses.