Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
There are two techniques that can be used to populate a QTextDocument: give it a QString of HTML-formatted text, or use a QTextCursor. We will show both approaches in this section, starting with the use of HTML.
Of course, in some cases, we don’t need a document at all, but simply want to render our data into a file in a standard format or to print our data. In such cases—and providing we don’t need HTML or ODF output—we can avoid using a QTextDocument at all and simply use a QPainter; this is covered in this chapter’s last section (
379).