QTextBrowser or QWebView?
Asked Answered
B

1

6

I need to render some HTML content (created by the application) and I'm wondering whether I should use QTextBrowser or QWebView. Although they seem quite similar, the doc doesn't discuss the differences between then.

I guess QWebView is almost a full-featured browser, but how about QTextBrowser? Does it also use webkit? Am I likely to run into some limitations if I use it?

Bartram answered 1/12, 2011 at 5:52 Comment(0)
O
9

QTextBrowser supports only a subset of HTML and CSS, documenation see here. It has the advantage that it is lightweight, QWebView uses a lot more code and ressources.

Some more information The answer is accurate, however I feel compelled to complete it with some more info (OP). As a warning, read through the provided link to get the tags and styles that work. em sizes don't seem to work at all so set all your sizes in pixels; HR styling is extremely limited; bottom-border styling is not available (which could have been a good alternative to HR); . So don't do your design in Firefox and expect it's going to work in Qt. It most likely won't. Check the ref when things don't work as you except and tweak as you go. Eventually, it's probably possible to do many designs with QTextBrowser but it's better to check as you go.

Odetteodeum answered 1/12, 2011 at 7:9 Comment(3)
Thanks for the link. Do you know if QTextBrowser in general is good to display table-less layouts?Bartram
It sure is good enough to display almost all conceivable static layout if you can restrict the HTML content to the (large) subset of HTML that the Richtext engine supports. The main thing that is not supported is Javascript.Odetteodeum
Thanks to Alexandre for updating this old answer!Odetteodeum

© 2022 - 2024 — McMap. All rights reserved.