内容表

上一话题

QTapGesture

下一话题

QTextEdit

QTextBrowser

QTextBrowser 类提供具有超文本导航的富文本浏览器。 更多

Inheritance diagram of PySide2.QtWidgets.QTextBrowser

概要

虚函数

信号

详细描述

此类扩展 QTextEdit (以只读模式),添加一些导航功能,以便用户可以在超文本文档中跟随链接。

If you want to provide your users with an editable rich text editor, use QTextEdit . If you want a text browser without hypertext navigation use QTextEdit , and use setReadOnly() to disable editing. If you just need to display a small piece of rich text use QLabel .

文档源和内容

The contents of QTextEdit are set with setHtml() or setPlainText() ,但 QTextBrowser also implements the setSource() function, making it possible to use a named document as the source text. The name is looked up in a list of search paths and in the directory of the current document factory.

If a document name ends with an anchor (for example, “ #anchor" ), the text browser automatically scrolls to that position (using scrollToAnchor() ). When the user clicks on a hyperlink, the browser will call setSource() itself with the link’s href value as argument. You can track the current source by connecting to the sourceChanged() 信号。