Drawing via QPainter
Before we get started, let me introduce the QPainter
class to you. This class performs low-level painting on widgets and other paint devices. In fact, everything drawn on the screen in a Qt application is the result of QPainter
. It can draw almost anything, including simple lines and aligned text. Thanks to the high-level APIs that Qt has provided, it's extremely easy to use these rich features.
Qt's paint system consists of QPainter
, QPaintDevice
, and QPaintEngine
. In this chapter, we won't need to deal with the latter two. The relations diagram is sketched as follows:
QPainter
is used to perform drawing operations, while QPaintDevice
is an abstraction of a two-dimensional space that can be painted on by using QPainter
. QPaintEngine
provides the interface that the painter uses to draw onto different types of devices. Note that the QPaintEngine
class is used internally by QPainter
and QPaintDevice
. It's also designed to be hidden from programmers...