Qt World Summit: Register Today!

Does QT support embedded images per the Microsoft .RTF specification ?

  • Specifically, I want to embed images, created from stored Blob data in a database, and email a created document to another computer. Basically, all the image data is contained within the rtf document. It can then be read on another computer, in Word or any editor that supports rtf, and have those images properly rendered.

    We have an older existing C++/MFC app that currently does this and I'm researching the viability of using QT for a re-write.

    I guess a more general question would be, how much of the RTF specification does QT support ?

    Any help would be appreciated.


  • Hi,

    Qt doesn't support RTF. Qt's rich text editing framework supports exporting a text document as plain text, PDF or ODF document.

    But you may want to look at Calligra Office Suite of KDE or Libreoffice. Calligra is developed using Qt so they may have a suitable library for handling such document formats.

    On the other hand, do you really need a text format to send around images? Why don't send the images as images?

  • Thanks for the reply, and sorry for being so long winded. I'll try to explain the scenario.

    Our main concerns are the ability to convert existing customer data in the field, importing/exporting from/to MS Word and WordPad and supporting copy and paste with text and images, to/from these apps.

    We have an existing customer base that likes the portability of .rtf files. Having rich text and graphics together in the same file streamlines everything. The graphics are small images associated with the text, there are a lot of them, they are position sensitive in the document, and easily can be copied/pasted to/from other apps that support .RTF. Our app creates these images programmatically, so they never exist as separate files outside of the documents, however they do get saved to a database as blob data, creating somewhat of an organized library of images,

    Then I'm assuming that Qt will not handle text and images copy/pasted from Word ??

    We've had a large number of requests for a Mac version of our software and since it's long past time for a rewrite, I'm looking into Qt. RTF on the Mac is not an issues as we have no current customers on Mac. PDF or ODF format sounds like acceptable alternatives. But this becomes problematic for MS Word users on Windows. I do see that there are some free converters out there that we can possibly package with our app, but it would be nice to have something internal. I'm not familiar with Calligra Office Suite of KDE or Libreoffice but I'll take a look.

    It doesn't appear that wxWidgets support rtf either, so the only other alternative I see would be to skip Qt and write separate native front ends, using a RichTextBox on Windows and some alternative on Mac.

    I've been a Microsoft developer for decades but I'll admit to being a total novice on the Mac. So I'm open to suggestions.

    Thanks again

  • [quote author="boatless" date="1420926927"]
    Then I'm assuming that Qt will not handle text and images copy/pasted from Word ??

    Qt has QTextEdit widget which supports "rich text":http://doc.qt.io/qt-5/richtext.html, not to be confused with MS RTF, and Qt also supports drag-and-drop, MIME and pasting content into widgets that support it. What Qt doesn't support is exporting contents of a QTextEdit, content is actually held in a QTextDocument instance, in MS RTF format.

  • Thanks for the input. I think the best think would be for me to download Qt and do some experimenting. If I can find a reasonable work around, QT would save a lot of hassle and time for cross platform. But we definitely need to convert existing customer data, currently stored in database, in RTF format, to something that can be loaded into QTextEdit, without losing the images.

    Is there a specification document available for the internal format used by QTextEdit ? It seems to be a subset of HTML. I did find some C++ code for converting RTF to HTML, If I had a complete listing of what is supported, it may be possible to write a home grown RTF<-->QText conversion utility, not that I want to, but it might be a fun project for a rainy weekend (<:

    Thanks again.

  • Qt's rich text editing is not about document formats such as HTML or PDF. These are formats supported (or not) to export the document.

    The link I have provided before is the main documentation page for rich text editing in Qt.As you will see there, you create and edit a document using Qt's relevant C++ classes. The names of the classes, such as QTextDocument or QTextEdit, can be confusing but these are pure C++ classes. The way they related to "physical" documents is that you can export a QTextDocument to one of the 3 types of document formats, and import from 2 of those.

    I strongly recommend that you look at the documentation and some of the examples to find out what you can do and you can't.

  • I missed that link... But that's just what I needed, the supported html tags.in QT. I think we'll need to know this in order to convert our existing rtf customer data, stripping out the images and save them as QT Resources. Then when a users desires to edit one of the stored documents, we can use setHTML to load the data into QTextEdit.

    Didn't mean to drag this out, but I think I've got more than enough info to warrant a closer look and some experimenting.

    Thanks again for all your help...it's much appreciated/

Log in to reply