CHAPTER 7Drawing and Printing
All painting in Qt is performed through the
QPainter class in one way or another. Widgets, pictures, delegates—everything uses the same mechanism. There is actually one exception to the rule (to use OpenGL directly), but you'll start with the
Using Qt you can draw on almost anything: widgets, pictures, pixmaps, images, printers, OpenGL areas, and so on. The common base class of all these drawables is the
Since a widget is a paint device, you can easily create a
QPainter for drawing onto the widget; simply pass
this as argument to the constructor, as shown in Listing 7-1.
Listing 7-1. Pass
this as argument to the
QPainter constructor from a paint event handler ...