MorrisLiang
9th October 2010, 11:26
QTextDocument* myTextDoc = myTextBrowser->document();
myTextDoc->addResource(QTextDocument::ImageResource,QUrl("relatedImage.jpg"),QVariant(relatedImg));
I'm trying to show a QPixmap in a QTextBrowser. I add the QPixmap relatedImg as a resource of the QTextDocument. Then I call QTextBrowser::setHtml("<img src='relatedImage.jpg'/>") to show it.
It works. But here're some questions.
1. Does QVariant(relatedImg) makes a full copy of the relatedImg?
2. How can I remove that resource when I don't need to show it anymore?
3. If relatedImg is updated (its content changed), do I need to call
myTextDoc->addResource(QTextDocument::ImageResource,QUrl("relatedImage.jpg"),QVariant(relatedImg)); again?
myTextDoc->addResource(QTextDocument::ImageResource,QUrl("relatedImage.jpg"),QVariant(relatedImg));
I'm trying to show a QPixmap in a QTextBrowser. I add the QPixmap relatedImg as a resource of the QTextDocument. Then I call QTextBrowser::setHtml("<img src='relatedImage.jpg'/>") to show it.
It works. But here're some questions.
1. Does QVariant(relatedImg) makes a full copy of the relatedImg?
2. How can I remove that resource when I don't need to show it anymore?
3. If relatedImg is updated (its content changed), do I need to call
myTextDoc->addResource(QTextDocument::ImageResource,QUrl("relatedImage.jpg"),QVariant(relatedImg)); again?