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

Diego Schulz dschulz at gmail.com
Sun Feb 12 21:06:47 CET 2012


On Tue, Feb 7, 2012 at 1:55 PM, paulovictor.pinheiro at gmail.com <
paulovictor.pinheiro at gmail.com> wrote:

> 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
>
>
Just a shoot in the dark: is it possible that imageFormat instance goes out
of scope and is already destroyed by the time
m_doc->toHtml() is called?

Regards,

diego



> _______________________________________________
> Interest mailing list
> Interest at qt-project.org
> http://lists.qt-project.org/mailman/listinfo/interest
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20120212/cc594c12/attachment.html>


More information about the Interest mailing list