Search code examples
htmlc++qthtml-generation

Generate HTML using Qt


I try to programmatically generate HTML using Qt 5.7 and C++.

I would like to avoid using simple text streaming since this does not check HTML syntax.

I tried to use QTextDocument and toHtml() but it seems not to work very well. It generally supports a small HTML subset only and a lot of standard elements must still be coded into strings manually.

Is there a clean way to generate HTML code using Qt/C++? Maybe some class that does for HTML what QDomDocument does for XML?


Solution

  • I ended creating my own template and DOM bases template classes supporting the HTML subset I need.