QTextBrowser 还是 QWebView?
我需要渲染一些 HTML 内容(由应用程序创建),我想知道是否应该使用 QTextBrowser 还是 QWebView。尽管它们看起来非常相似,但文档没有讨论它们之间的差异。
我猜 QWebView 几乎是一个全功能的浏览器,但是 QTextBrowser 怎么样?它也使用webkit吗?如果我使用它,我可能会遇到一些限制吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
QTextBrowser 仅支持 HTML 和 CSS 的子集,文档请参见此处。
它的优点是轻量级,QWebView使用了更多的代码和资源。
一些更多信息答案是准确的,但我觉得有必要用一些更多信息来完成它(OP)。作为警告,请仔细阅读提供的链接以获取有效的标签和样式。
em
尺寸似乎根本不起作用,因此请以像素为单位设置所有尺寸; HR 风格极其有限;bottom-border
样式不可用(这可能是 HR 的一个很好的替代方案); 。因此,不要在 Firefox 中进行设计并期望它能在 Qt 中工作。很可能不会。当事情无法按照您的方式工作时,请检查参考文献,并随时进行调整。最终,可能可以使用 QTextBrowser 进行许多设计,但最好边做边检查。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.