May 2019
Intermediate to advanced
542 pages
13h 37m
English
At last, we get to meet the QPainter class! QPainter can be thought of as a little robot that lives inside your screen—to whom we can provide a brush and a pen, and issue drawing commands.
Let's create our painting robot:
painter = qtg.QPainter(self.image)
The painter's constructor is passed a reference to the object on which it will paint. The object to be painted must be a subclass of QPaintDevice; in this case, we're passing a QImage object, which is such a class. The passed object will be the painter's canvas on which the painter will draw when we issue drawing commands.
To see how basic painting works, let's start with our top and bottom background blocks. We'll first figure out the boundaries of the rectangles that ...
Read now
Unlock full access