Book Image

Application Development with Qt Creator - Second Edition

Book Image

Application Development with Qt Creator - Second Edition

Overview of this book

Table of Contents (20 chapters)
Application Development with Qt Creator Second Edition
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Chapter 6. Drawing with Qt

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, I will show you what you need to know for general drawing in Qt. We begin by discussing QPainter and how it uses QPaintDevice instances to abstract drawing functionality. I will show you 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 to a newer and lower level of abstraction Qt provides for graphics management, the graphics view/graphics scene...