I am trying to set the contents of a image file to QTextDocument so that i can send it to the printer but i am not able to get the contents of the file in the QTextDocument.
Some thing like following works
QTextDocument* document = new QTextDocument("Text");
To copy to clipboard, switch view to plain text mode
But i dont want to pass the string i want the contents of a file. which is not working and the document is empty. Am I not using the addresource porperly. is there any other way to set the file contents to QTextDocument ?
const QUrl url
= QUrl::fromLocalFile ( "/tmp/test.png" ) ;
if (document->isEmpty())
fprintf(stderr,"Document is empty");
const QUrl url = QUrl::fromLocalFile ( "/tmp/test.png" ) ;
QTextDocument* document = new QTextDocument();
document->addResource (QTextDocument::ImageResource, url, QVariant(QImage("/tmp/test.png")));
if (document->isEmpty())
fprintf(stderr,"Document is empty");
To copy to clipboard, switch view to plain text mode
Bookmarks