PDA

View Full Version : Qt 4.4.0 printing images



ad5xj
30th May 2008, 17:40
I must admit I am not up to speed on printing images. But I have a question in that regard.

I am printing a QTextEdit object to QPrinter using a QTextCursor to format the rich text on a page. I have formatted the image and text but each time I try to print the image I just get the default "empty" image (you know - the page icon with the top corner turned down) with the right dimensions not my real graphic. The text prints as formatted.

I am assuming (bad idea of course) that since the "empty" image is displayed that the syntax is correct. But why is the image not inserted into the cursor? It is present in the resources and called by the correct name.

What am I missing?

jacek
3rd June 2008, 23:07
How do you insert that image exactly?

This way?

QImage img = ...
textDocument->addResource(QTextDocument::ImageResource, QUrl("myimage"), img);
cursor.insertImage("myimage");