Results 1 to 2 of 2

Thread: QTextDocument not keeping its format when saving to ODF file

  1. #1
    Join Date
    Mar 2010
    Posts
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default QTextDocument not keeping its format when saving to ODF file

    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.

    Qt Code:
    1. QTextDocument *m_document = new QTextDocument;
    2. editor->setDocument(m_document);
    To copy to clipboard, switch view to plain text mode 

    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.

    Qt Code:
    1. QTextDocumentWriter m_write;
    2. m_write.setFileName("orderform.odf");
    3. m_write.setFormat("odf");
    4. m_write.write(m_document);
    To copy to clipboard, switch view to plain text mode 

    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.
    odf_output.jpg

    Here is the desired output.
    orderform.JPG

  2. #2
    Join Date
    May 2011
    Posts
    1
    Qt products
    Qt4
    Platforms
    Windows

    Default Re: QTextDocument not keeping its format when saving to ODF file

    Same problem for me with QT 4.7.3 and win7. Any suggestion?

Similar Threads

  1. Problems saving a text file
    By aarelovich in forum Qt Programming
    Replies: 3
    Last Post: 27th September 2009, 14:39
  2. Saving a password in a file
    By srohit24 in forum Qt Programming
    Replies: 12
    Last Post: 25th June 2009, 07:50
  3. Saving image in jpeg format failed
    By febil in forum Qt Programming
    Replies: 5
    Last Post: 23rd April 2009, 11:33
  4. Insert SVG file into QtextDocument
    By giusepped in forum Qt Programming
    Replies: 1
    Last Post: 14th April 2009, 04:15
  5. How to convert QTextDocument to PNG file?
    By Gonzalez in forum Qt Programming
    Replies: 1
    Last Post: 2nd February 2006, 14:46

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.