How do I set line spacing after a wordwrap in QTextBrowser? Ie. how dow I set line height?
A:
Looking through the docs, it doesn't look like the HTML subset that QTextBrowser supports would allow you to adjust the line space (though should be able to adjust the paragraph spacing).
It's a much heavier weight solution, but you could try using QWebView instead.
Kitsune
2010-05-01 01:48:51
no QWebWiew is indeed too heavy for my application.
Regof
2010-05-01 09:51:24
+1
A:
You should be able to achive this by setting an appropriate stylesheet.
Edit: I was mistaken with the initial reply -- setStyleSheet()
works on the widget, not its contents. However, you can achieve the behaviour by formatting your text as HTML with stylesheet formatting, and then setting that as the text in your QTextBrowser
. Example:
QTextBrowser *browser = new QTextBrowser();
QString text;
text.append("<html><body>");
text.append("<style type='text/css'>p { margin-bottom:20px; }</style>");
// add the paragraphs here. If the input is plain text convert it to HTML paragraphs first.
text.append("<p>Paragraph 1</p>");
text.append("<p>Paragraph 2</b>");
text.append("</body></html>");
browser->setHtml(text);
bluebrother
2010-05-01 10:08:11
I was mistaken with my initial answer. Using the stylesheet formatting in the QTextBrowser itself works if you set it with setHtml(). I've edited my answer, and added a small example.
bluebrother
2010-05-01 17:56:02