Reputation: 21
I tried aligning my text using both CSS and HTML but none of them work. Somehow HTML align attribute works for h1 and h2 but not for div or span.
QTextDocument doc;
doc.setDefaultStyleSheet("div{ align-content: center ; font: italic 15px ; color:green;}");
doc.setHtml(
"<h1 align='center'>LOL </h1 > "
"<h2 align='right'>lolh </h2 ><hr><br>"
"<div align='centre'>"
"<span align='centre'> lol1 : "+ compname +"</span><br><br>"
"<span align='right'>lol2 : "+ worktype +"</span><br><br>"
"</div>"
"<h2 align='right'>lolH </h2 ><hr><br>"
"<span align='right'>lol3 :</span><br><br>"
)
Out of every alignment attempt used, only the h1 and h2 attributes work and I have no idea why. Can you help me?
Upvotes: 1
Views: 2006
Reputation: 21
Use doc.setTextWidth(...)
to enable text alignment (see QTBUG-22851).
Upvotes: 2