Your code never tries to insert an image into a QTextDocument. Inserting an image is done with QTextCursor::insertImage() and a suitable QTextImageFormat that names an image resource that has been added using QTextDocument::addResource(). The last link shows an example of this process.
I have not tried it, but I expect that calling QTextDocument::setHtml() with HTML that references an accessible image through an img element should also work.
What your code does is try to paint an image onto a QPainter that is not associated with a paint device (through the constructor or QPainter::begin()). You then draw the contents of the QTextDocument into the same uninitialised painter. When you finally call QTextDocument::print() the document is unchanged and image free.
Bookmarks