Simply creating a document in colour
-
You can use QTextDocumentWriter to output a QTextDocument to a supported format.
Unfortunately, QTextDocument does not support RTF as an output format. Only plain text, HTML and ODF are supported. I did not find an easy way to add support for a format either, though I might have just overlooked this in the documentation. The API design seems to have been done in a way that this should be possible though.
-
Yes, ODF supports colored text. I am, however, not 100% positive that QTextDocumentWriter supports that feature of ODF, but that would be a simple test to make yourself, would it not?
The documentation of QTextDocumentWriter is quite clear, and the interface quite simple, I think. Is there anything in there you don't understand specifically?
-
-
[quote author="Gerolf" date="1301914256"]I just had a look at the code of QTextEdit which (per documentation) also accepts RichText format, built only for user input (drag and drop, copy/paste) :-(
SO I'm afraid, only plaintext, odf or html is possible (without extra coding)[/quote]
That might actually warrant a feature request: add RTF to the list of supported formats for QTextDocumentWriter, and make it possible to add custom formats for that. -
OK, fair enough:
- "Make list of supported QTextDocumentWriter formats extendible":http://bugreports.qt.nokia.com/browse/QTBUG-18570
- "Add support for RTF to QTextDocumentWriter":http://bugreports.qt.nokia.com/browse/QTBUG-18571