Results 1 to 2 of 2

Thread: create .odt with headings and table

  1. #1
    Join Date
    May 2009
    Posts
    75
    Thanks
    5
    Qt products
    Qt4 Qt/Embedded
    Platforms
    Unix/X11 Windows

    Default create .odt with headings and table

    I need to create a .odt file that contains headings (such as heading 1 or heading 2) and tables.

    I tried something like this:
    Qt Code:
    1. #include <QString>
    2. #include <QTextStream>
    3. #include <QTextDocument>
    4. #include <QTextDocumentWriter>
    5.  
    6. int main(void)
    7. {
    8. QString strStream;
    9. QTextStream out(&strStream);
    10.  
    11. QTextDocument *document = new QTextDocument();
    12.  
    13. out << "<!DOCTYPE html>"
    14. << "<html>\n"
    15. << "<head>"
    16. << "<title>Test</title>"
    17. << "</head>"
    18. << "<body>"
    19. << "<h1>Test heading 1</h1>"
    20. << "</body>"
    21. << "</html>";
    22. document->setHtml(strStream);
    23.  
    24. QTextDocumentWriter writer("test.odt");
    25.  
    26. writer.setFormat("odf");
    27. writer.write(document);
    28.  
    29. delete document;
    30. return 0;
    31. }
    To copy to clipboard, switch view to plain text mode 

    but the product .odt file has no heading.
    Screenshot_2018-08-01_16-50-50.png
    what I would like to be heading 1 doesn't have the Heading 1 style, but, in fact, it's a Default Style bold text.

    How do I force Heading 1 style?

    best regards
    Max

  2. #2
    Join Date
    Jan 2006
    Location
    Warsaw, Poland
    Posts
    33,355
    Thanks
    3
    Thanked 5,009 Times in 4,788 Posts
    Qt products
    Qt3 Qt4 Qt5 Qt/Embedded
    Platforms
    Unix/X11 Windows Android Maemo/MeeGo
    Blog Entries
    4
    Wiki edits
    10

    Default Re: create .odt with headings and table

    I don't think Qt stores information about headings anywhere so it's likely you simply can't do that.
    Your biological and technological distinctiveness will be added to our own. Resistance is futile.

    Please ask Qt related questions on the forum and not using private messages or visitor messages.


Similar Threads

  1. Create sqlite table is not work
    By galaxy66 in forum Qt Programming
    Replies: 2
    Last Post: 1st March 2016, 12:14
  2. To Show images in QListWidget with headings.
    By merry in forum Qt Programming
    Replies: 0
    Last Post: 9th October 2015, 12:22
  3. Replies: 5
    Last Post: 3rd April 2010, 05:07
  4. Can't create table
    By waynew in forum Newbie
    Replies: 7
    Last Post: 30th October 2009, 23:13
  5. How create a two level table?
    By kaushal_gaurav in forum Qt Programming
    Replies: 3
    Last Post: 29th October 2008, 19:16

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.