PDA

View Full Version : QTextDocument not keeping its format when saving to ODF file



abe
1st March 2010, 17:49
Greetings,

First of all, my development environment is RedHat Linux, Qt 4.6.2, QtCreator 1.3.1, gcc/g++ 4.1.1

I'm currently trying to export a formatted document to ODF. I'm using the orderform example located in /QT/4.6.2/examples/richtext/orderform. (http://doc.trolltech.com/4.6/richtext-orderform.html)

The example writes richtext into a QTextEdit object. I want to save the contents in the QTextEdit object into an ODF file. I added a QTextDocument object to the sample code.



QTextDocument *m_document = new QTextDocument;
editor->setDocument(m_document);


After the data (Frames, Tables, formatted text) is added to the QTextEdit object, I add a QTextDocumentWriter object to save the contents of the QTextEdit/QTextDocument to an ODF file.



QTextDocumentWriter m_write;
m_write.setFileName("orderform.odf");
m_write.setFormat("odf");
m_write.write(m_document);


My problem is that the ODF file layout is not formatted the same way as what is shown in the QTextEdit Object. All the text and tables seem to be there but they do not keep the same alignment, size, or positioning in the ODF file. The only thing that seems to be formatted correctly is the font style.

Is there a way to create an ODF file that is properly formatted from within Qt?

Any help is greatly appreciated. Thanks in advanced.

Here is a screenshot of the ODF file.
4358

Here is the desired output.
4357

miimote
25th May 2011, 19:25
Same problem for me with QT 4.7.3 and win7. Any suggestion?