take a look at this method
void QTextDocument::drawContents ( QPainter * p, const QRectF & rect = QRectF() )