At its core, graphics painting requires two things: something that knows how to paint, and something that can be painted on. Qt defines the QPainter class as the former, and the QPaintDevice as the interface for classes for the latter. You'll seldom instantiate each, but you use both of these classes a lot if you're doing graphics programming; typically, you'll have an instance of a subclass of QPaintDevice, ask it for its associated QPainter, and then use QPainter to perform your drawing. This can happen when you're writing a widget; you'll be passed a QPainter subclass, for example, when you need to paint the widget's contents.
There are several subclasses of QPaintDevice, as follows:
- QWidget: This class and its subclasses are used by the widget hierarchy.
- QImage: This is a container class for offscreen...