QTextBrowser¶

The QTextBrowser class provides a rich text browser with hypertext navigation. More…

Inheritance diagram of PySide2.QtWidgets.QTextBrowser

Synopsis¶

Functions¶

  • def backwardHistoryCount ()

  • def clearHistory ()

  • def doSetSource (name[, type=QTextDocument.UnknownResource])

  • def forwardHistoryCount ()

  • def historyTitle (arg__1)

  • def historyUrl (arg__1)

  • def isBackwardAvailable ()

  • def isForwardAvailable ()

  • def openExternalLinks ()

  • def openLinks ()

  • def searchPaths ()

  • def setOpenExternalLinks (open)

  • def setOpenLinks (open)

  • def setSearchPaths (paths)

  • def source ()

  • def sourceType ()

Virtual functions¶

  • def backward ()

  • def forward ()

  • def home ()

  • def reload ()

  • def setSource (name)

Slots¶

  • def setSource (name, type)

Signals¶

  • def anchorClicked (arg__1)

  • def backwardAvailable (arg__1)

  • def forwardAvailable (arg__1)

  • def highlighted (arg__1)

  • def highlighted (arg__1)

  • def historyChanged ()

  • def sourceChanged (arg__1)

Detailed Description¶

This class extends 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 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 .

Document Source and Contents¶

The contents of QTextEdit are set with setHtml() or setPlainText() , but 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() signal.