QTextBrowser

Inheritance diagram of PySide2.QtWidgets.QTextBrowser

Synopsis

Functions

Virtual functions

Signals

Detailed Description

The PySide2.QtWidgets.QTextBrowser class provides a rich text browser with hypertext navigation.

This class extends PySide2.QtWidgets.QTextEdit (in read-only mode), adding some navigation functionality so that users can follow links in hypertext documents.

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

Document Source and Contents

The contents of PySide2.QtWidgets.QTextEdit are set with PySide2.QtWidgets.QTextEdit.setHtml() or PySide2.QtWidgets.QTextEdit.setPlainText() , but PySide2.QtWidgets.QTextBrowser also implements the PySide2.QtWidgets.QTextBrowser.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 PySide2.QtWidgets.QTextEdit.scrollToAnchor() ). When the user clicks on a hyperlink, the browser will call PySide2.QtWidgets.QTextBrowser.setSource() itself with the link’s href value as argument. You can track the current source by connecting to the PySide2.QtWidgets.QTextBrowser.sourceChanged() signal.