While many applications can be built using only the built-in widgets, others require the ability to perform custom drawing—for example, when you need a custom widget or two, or maybe you're doing offscreen rendering to programmatically create images in graphics files, or else you're interested in building a radically different user interface. Qt provides support for all of these scenarios in C++, in addition to what you can do with Qt Quick.
In this chapter, we will see what is needed to know for general drawing in Qt. We begin by discussing QPainter, and how it uses QPaintDevice instances to abstract drawing functionality. We will see how this works in general terms, and then give concrete examples for offscreen drawing to bitmaps, as well as creating custom widgets that interoperate with Qt Widgets. In the last half of the chapter, we will turn...