I am using QTextDocumentWriter to write my QTextDocument, but here along with the document i want to write a file and add a link to the file in the document. I have added the link and it is working, but i want to write the document or not depends on whether user does export. For that I want to add the file to the document resource using the QTextDocument::addResource which will hold the QFile so that i could get the file when i want to write it.