mastupristi
1st August 2018, 16:05
I need to create a .odt file that contains headings (such as heading 1 or heading 2) and tables.
I tried something like this:
#include <QString>
#include <QTextStream>
#include <QTextDocument>
#include <QTextDocumentWriter>
int main(void)
{
QString strStream;
QTextStream out(&strStream);
QTextDocument *document = new QTextDocument();
out << "<!DOCTYPE html>"
<< "<html>\n"
<< "<head>"
<< "<title>Test</title>"
<< "</head>"
<< "<body>"
<< "<h1>Test heading 1</h1>"
<< "</body>"
<< "</html>";
document->setHtml(strStream);
QTextDocumentWriter writer("test.odt");
writer.setFormat("odf");
writer.write(document);
delete document;
return 0;
}
but the product .odt file has no heading.
12910
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
I tried something like this:
#include <QString>
#include <QTextStream>
#include <QTextDocument>
#include <QTextDocumentWriter>
int main(void)
{
QString strStream;
QTextStream out(&strStream);
QTextDocument *document = new QTextDocument();
out << "<!DOCTYPE html>"
<< "<html>\n"
<< "<head>"
<< "<title>Test</title>"
<< "</head>"
<< "<body>"
<< "<h1>Test heading 1</h1>"
<< "</body>"
<< "</html>";
document->setHtml(strStream);
QTextDocumentWriter writer("test.odt");
writer.setFormat("odf");
writer.write(document);
delete document;
return 0;
}
but the product .odt file has no heading.
12910
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