Paint Html formating correctly ?
-
Hello there!
I want to paint a text formating in html, this is what I do :QTextDocument HtmlTxt; QTextOption textOption; QString templateHtml; textOption.setAlignment(Qt::AlignJustify); textOption.setWrapMode(QTextOption::WordWrap); HtmlTxt.setDefaultTextOption(textOption); templateHtml = "<html><head><style>body{font-size:32px;}</style></head><body>{{%BODY%}}</body></html>"; HtmlTxt.setTextWidth(rect.width()); HtmlTxt.setHtml( templateHtml.replace("{{%BODY%}}", text ); painter.save(); painter.translate(rect.topLeft()); HtmlTxt.drawContents(&painter); painter.restore(); // Draw below this content but, where I am ?
It's working, but After that I don"t know where is my rect.bottom ? to continue the painter.
Is it the good way to paint a HTML text ?
Thanks -
@cfdev
note that QTextDocument does only support a rich text HTML subsetSince you already have a QTextDocument you can query it's size and other properties (like documentMargin, etc)
-
@raven-worx
note that QTextDocument does only support a rich text HTML subset
yes I need juste the base formating, <strong>, <ul>, <i>....Since you already have a QTextDocument you can query it's size and other properties (like documentMargin, etc)
Thanks It's what I needed ! ;) -
@cfdev said in Paint Html formating correctly ?:
yes I need juste the base formating, <strong>, <ul>, <i>....
no, you are also using a style tag with CSS in it:
<style>body{font-size:32px;}</style>