[Interest] QTextEdit::toHtml() crash when a image is inserted

paulovictor.pinheiro at gmail.com paulovictor.pinheiro at gmail.com
Tue Feb 7 17:55:58 CET 2012


Hello there,

I'm having a problem with QTextEdit/QTextDocument when i'm trying to export
the document to html via QTextEdit::toHtml() . The problem lies when we
insert an image using QTextDocument::addResource() and, although QTextEdit
shows it fine, it crashes when we call QTextEdit::toHtml() function. Any
words of advice? Some snippet above:

...
QImage img(img1Path);

QUrl uri = QUrl::fromLocalFile(img1Path);

m_doc->addResource(QTextDocument::ImageResource, uri, QVariant(img));

QTextImageFormat imageFormat;
imageFormat.setWidth(300);
imageFormat.setHeight(300);
imageFormat.setName(uri.toString());

cursor.insertImage(imageFormat);
...

// when it crashes
QString html = m_doc->toHtml();

It works fine when a image is not inserted.

Att,

Paulo Pinheiro
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20120207/72b57fd8/attachment.html>


More information about the Interest mailing list