Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
QTextBrowser Class Reference

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

#include <qtextbrowser.h>

+ Inheritance diagram for QTextBrowser:
+ Collaboration diagram for QTextBrowser:

Public Slots

void setSource (const QUrl &name, QTextDocument::ResourceType type=QTextDocument::UnknownResource)
 Attempts to load the document at the given url with the specified type.
 
virtual void backward ()
 Changes the document displayed to the previous document in the list of documents built by navigating links.
 
virtual void forward ()
 Changes the document displayed to the next document in the list of documents built by navigating links.
 
virtual void home ()
 Changes the document displayed to be the first document from the history.
 
virtual void reload ()
 Reloads the current set source.
 
- Public Slots inherited from QTextEdit
void setFontPointSize (qreal s)
 Sets the point size of the current format to s.
 
void setFontFamily (const QString &fontFamily)
 Sets the font family of the current format to fontFamily.
 
void setFontWeight (int w)
 Sets the font weight of the current format to the given weight, where the value used is in the range defined by the QFont::Weight enum.
 
void setFontUnderline (bool b)
 If underline is true, sets the current format to underline; otherwise sets the current format to non-underline.
 
void setFontItalic (bool b)
 If italic is true, sets the current format to italic; otherwise sets the current format to non-italic.
 
void setTextColor (const QColor &c)
 Sets the text color of the current format to c.
 
void setTextBackgroundColor (const QColor &c)
 
void setCurrentFont (const QFont &f)
 Sets the font of the current format to f.
 
void setAlignment (Qt::Alignment a)
 Sets the alignment of the current paragraph to a.
 
void setPlainText (const QString &text)
 Changes the text of the text edit to the string text.
 
void setHtml (const QString &text)
 
void setText (const QString &text)
 
void cut ()
 Copies the selected text to the clipboard and deletes it from the text edit.
 
void copy ()
 Copies any selected text to the clipboard.
 
void paste ()
 Pastes the text from the clipboard into the text edit at the current cursor position.
 
void undo ()
 
void redo ()
 
void clear ()
 Deletes all the text in the text edit.
 
void selectAll ()
 Selects all text.
 
void insertPlainText (const QString &text)
 Convenience slot that inserts text at the current cursor position.
 
void insertHtml (const QString &text)
 Convenience slot that inserts text which is assumed to be of html formatting at the current cursor position.
 
void append (const QString &text)
 Appends a new paragraph with text to the end of the text edit.
 
void scrollToAnchor (const QString &name)
 Scrolls the text edit so that the anchor with the given name is visible; does nothing if the name is empty, or is already visible, or isn't found.
 
void zoomIn (int range=1)
 Zooms in on the text by making the base font size range points larger and recalculating all font sizes to be the new size.
 
void zoomOut (int range=1)
 Zooms out on the text by making the base font size range points smaller and recalculating all font sizes to be the new size.
 

Signals

void backwardAvailable (bool)
 This signal is emitted when the availability of backward() changes.
 
void forwardAvailable (bool)
 This signal is emitted when the availability of forward() changes.
 
void historyChanged ()
 
void sourceChanged (const QUrl &)
 This signal is emitted when the source has changed, src being the new source.
 
void highlighted (const QUrl &)
 This signal is emitted when the user has selected but not activated an anchor in the document.
 
void anchorClicked (const QUrl &)
 This signal is emitted when the user clicks an anchor.
 
- Signals inherited from QTextEdit
void textChanged ()
 This signal is emitted whenever the document's content changes; for example, when text is inserted or deleted, or when formatting is applied.
 
void undoAvailable (bool b)
 This signal is emitted whenever undo operations become available (available is true) or unavailable (available is false).
 
void redoAvailable (bool b)
 This signal is emitted whenever redo operations become available (available is true) or unavailable (available is false).
 
void currentCharFormatChanged (const QTextCharFormat &format)
 This signal is emitted if the current character format has changed, for example caused by a change of the cursor position.
 
void copyAvailable (bool b)
 This signal is emitted when text is selected or de-selected in the text edit.
 
void selectionChanged ()
 This signal is emitted whenever the selection changes.
 
void cursorPositionChanged ()
 This signal is emitted whenever the position of the cursor changed.
 

Public Member Functions

 QTextBrowser (QWidget *parent=nullptr)
 Constructs an empty QTextBrowser with parent parent.
 
virtual ~QTextBrowser ()
 
QUrl source () const
 
QTextDocument::ResourceType sourceType () const
 
QStringList searchPaths () const
 
void setSearchPaths (const QStringList &paths)
 
virtual QVariant loadResource (int type, const QUrl &name) override
 This function is called when the document is loaded and for each image in the document.
 
bool isBackwardAvailable () const
 
bool isForwardAvailable () const
 
void clearHistory ()
 
QString historyTitle (int) const
 Returns the documentTitle() of the HistoryItem.
 
QUrl historyUrl (int) const
 Returns the url of the HistoryItem.
 
int backwardHistoryCount () const
 Returns the number of locations backward in the history.
 
int forwardHistoryCount () const
 Returns the number of locations forward in the history.
 
bool openExternalLinks () const
 
void setOpenExternalLinks (bool open)
 
bool openLinks () const
 
void setOpenLinks (bool open)
 
- Public Member Functions inherited from QTextEdit
 QTextEdit (QWidget *parent=nullptr)
 Constructs an empty QTextEdit with parent parent.
 
 QTextEdit (const QString &text, QWidget *parent=nullptr)
 Constructs a QTextEdit with parent parent.
 
virtual ~QTextEdit ()
 Destructor.
 
void setDocument (QTextDocument *document)
 
QTextDocumentdocument () const
 
void setPlaceholderText (const QString &placeholderText)
 
QString placeholderText () const
 
void setTextCursor (const QTextCursor &cursor)
 Sets the visible cursor.
 
QTextCursor textCursor () const
 Returns a copy of the QTextCursor that represents the currently visible cursor.
 
bool isReadOnly () const
 
void setReadOnly (bool ro)
 
void setTextInteractionFlags (Qt::TextInteractionFlags flags)
 
Qt::TextInteractionFlags textInteractionFlags () const
 
qreal fontPointSize () const
 Returns the point size of the font of the current format.
 
QString fontFamily () const
 Returns the font family of the current format.
 
int fontWeight () const
 Returns the font weight of the current format.
 
bool fontUnderline () const
 Returns true if the font of the current format is underlined; otherwise returns false.
 
bool fontItalic () const
 Returns true if the font of the current format is italic; otherwise returns false.
 
QColor textColor () const
 Returns the text color of the current format.
 
QColor textBackgroundColor () const
 
QFont currentFont () const
 Returns the font of the current format.
 
Qt::Alignment alignment () const
 Returns the alignment of the current paragraph.
 
void mergeCurrentCharFormat (const QTextCharFormat &modifier)
 Merges the properties specified in modifier into the current character format by calling QTextCursor::mergeCharFormat on the editor's cursor.
 
void setCurrentCharFormat (const QTextCharFormat &format)
 Sets the char format that is be used when inserting new text to format by calling QTextCursor::setCharFormat() on the editor's cursor.
 
QTextCharFormat currentCharFormat () const
 Returns the char format that is used when inserting new text.
 
AutoFormatting autoFormatting () const
 
void setAutoFormatting (AutoFormatting features)
 
bool tabChangesFocus () const
 
void setTabChangesFocus (bool b)
 
void setDocumentTitle (const QString &title)
 
QString documentTitle () const
 
bool isUndoRedoEnabled () const
 
void setUndoRedoEnabled (bool enable)
 
LineWrapMode lineWrapMode () const
 
void setLineWrapMode (LineWrapMode mode)
 
int lineWrapColumnOrWidth () const
 
void setLineWrapColumnOrWidth (int w)
 
QTextOption::WrapMode wordWrapMode () const
 the mode QTextEdit will use when wrapping text by words
 
void setWordWrapMode (QTextOption::WrapMode policy)
 
bool find (const QString &exp, QTextDocument::FindFlags options=QTextDocument::FindFlags())
 Finds the next occurrence of the string, exp, using the given options.
 
QString toPlainText () const
 QString QTextEdit::toPlainText() const.
 
QString toHtml () const
 
void ensureCursorVisible ()
 Ensures that the cursor is visible by scrolling the text edit if necessary.
 
QMenucreateStandardContextMenu ()
 \reimp
 
QMenucreateStandardContextMenu (const QPoint &position)
 
QTextCursor cursorForPosition (const QPoint &pos) const
 returns a QTextCursor at position pos (in viewport coordinates).
 
QRect cursorRect (const QTextCursor &cursor) const
 returns a rectangle (in viewport coordinates) that includes the cursor.
 
QRect cursorRect () const
 returns a rectangle (in viewport coordinates) that includes the cursor of the text edit.
 
QString anchorAt (const QPoint &pos) const
 Returns the reference of the anchor at position pos, or an empty string if no anchor exists at that point.
 
bool overwriteMode () const
 
void setOverwriteMode (bool overwrite)
 
qreal tabStopDistance () const
 
void setTabStopDistance (qreal distance)
 
int cursorWidth () const
 
void setCursorWidth (int width)
 
bool acceptRichText () const
 
void setAcceptRichText (bool accept)
 
void setExtraSelections (const QList< ExtraSelection > &selections)
 \variable QTextEdit::ExtraSelection::cursor A cursor that contains a selection in a QTextDocument
 
QList< ExtraSelectionextraSelections () const
 
void moveCursor (QTextCursor::MoveOperation operation, QTextCursor::MoveMode mode=QTextCursor::MoveAnchor)
 
bool canPaste () const
 
void print (QPagedPaintDevice *printer) const
 
QVariant inputMethodQuery (Qt::InputMethodQuery property) const override
 \reimp
 
Q_INVOKABLE QVariant inputMethodQuery (Qt::InputMethodQuery query, QVariant argument) const
 

Protected Member Functions

bool event (QEvent *e) override
 \reimp
 
virtual void keyPressEvent (QKeyEvent *ev) override
 The event ev is used to provide the following keyboard shortcuts: \table \header.
 
virtual void mouseMoveEvent (QMouseEvent *ev) override
 \reimp
 
virtual void mousePressEvent (QMouseEvent *ev) override
 \reimp
 
virtual void mouseReleaseEvent (QMouseEvent *ev) override
 \reimp
 
virtual void focusOutEvent (QFocusEvent *ev) override
 \reimp
 
virtual bool focusNextPrevChild (bool next) override
 \reimp
 
virtual void paintEvent (QPaintEvent *e) override
 \reimp
 
virtual void doSetSource (const QUrl &name, QTextDocument::ResourceType type=QTextDocument::UnknownResource)
 Attempts to load the document at the given url with the specified type.
 
- Protected Member Functions inherited from QTextEdit
virtual void timerEvent (QTimerEvent *e) override
 
virtual void keyReleaseEvent (QKeyEvent *e) override
 \reimp
 
virtual void resizeEvent (QResizeEvent *e) override
 \reimp
 
virtual void mouseDoubleClickEvent (QMouseEvent *e) override
 \reimp
 
virtual void contextMenuEvent (QContextMenuEvent *e) override
 Shows the standard context menu created with createStandardContextMenu().
 
virtual void focusInEvent (QFocusEvent *e) override
 \reimp
 
virtual void showEvent (QShowEvent *) override
 \reimp
 
virtual void changeEvent (QEvent *e) override
 \reimp
 
virtual QMimeDatacreateMimeDataFromSelection () const
 This function returns a new MIME data object to represent the contents of the text edit's current selection.
 
virtual bool canInsertFromMimeData (const QMimeData *source) const
 This function returns true if the contents of the MIME data object, specified by source, can be decoded and inserted into the document.
 
virtual void insertFromMimeData (const QMimeData *source)
 This function inserts the contents of the MIME data object, specified by source, into the text edit at the current cursor position.
 
virtual void inputMethodEvent (QInputMethodEvent *) override
 \reimp
 
 QTextEdit (QTextEditPrivate &dd, QWidget *parent)
 
virtual void scrollContentsBy (int dx, int dy) override
 \reimp
 
virtual void doSetTextCursor (const QTextCursor &cursor)
 
void zoomInF (float range)
 

Properties

QUrl source
 the name of the displayed document.
 
QTextDocument::ResourceType sourceType
 the type of the displayed document
 
QStringList searchPaths
 the search paths used by the text browser to find supporting content
 
bool openExternalLinks
 
bool openLinks
 
- Properties inherited from QTextEdit
AutoFormatting autoFormatting
 the enabled set of auto formatting features
 
bool tabChangesFocus
 whether \uicontrol Tab changes focus or is accepted as input
 
QString documentTitle
 the title of the document parsed from the text.
 
bool undoRedoEnabled
 whether undo and redo are enabled.
 
LineWrapMode lineWrapMode
 the line wrap mode
 
int lineWrapColumnOrWidth
 the position (in pixels or columns depending on the wrap mode) where text will be wrapped
 
bool readOnly
 whether the text edit is read-only
 
QString html
 This property provides an HTML interface to the text of the text edit.
 
QString plainText
 the text editor's contents as plain text.
 
bool overwriteMode
 whether text entered by the user will overwrite existing text
 
qreal tabStopDistance
 the tab stop distance in pixels
 
bool acceptRichText
 whether the text edit accepts rich text insertions by the user
 
int cursorWidth
 
Qt::TextInteractionFlags textInteractionFlags
 
QTextDocumentdocument
 the underlying document of the text editor.
 
QString placeholderText
 the editor placeholder text
 

Additional Inherited Members

- Public Types inherited from QTextEdit
enum  LineWrapMode { NoWrap , WidgetWidth , FixedPixelWidth , FixedColumnWidth }
 \value NoWrap \value WidgetWidth \value FixedPixelWidth \value FixedColumnWidth More...
 
enum  AutoFormattingFlag { AutoNone = 0 , AutoBulletList = 0x00000001 , AutoAll = 0xffffffff }
 \value AutoNone Don't do any automatic formatting. More...
 

Detailed Description

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

\inmodule QtWidgets

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 QTextEdit::setReadOnly() to disable editing. If you just need to display a small piece of rich text use QLabel.

Definition at line 17 of file qtextbrowser.h.

Constructor & Destructor Documentation

◆ QTextBrowser()

QTextBrowser::QTextBrowser ( QWidget * parent = nullptr)
explicit

Constructs an empty QTextBrowser with parent parent.

Definition at line 692 of file qtextbrowser.cpp.

References d.

◆ ~QTextBrowser()

QTextBrowser::~QTextBrowser ( )
virtual

Definition at line 703 of file qtextbrowser.cpp.

Member Function Documentation

◆ anchorClicked

void QTextBrowser::anchorClicked ( const QUrl & link)
signal

This signal is emitted when the user clicks an anchor.

The URL referred to by the anchor is passed in link.

Note that the browser will automatically handle navigation to the location specified by link unless the openLinks property is set to false or you call setSource() in a slot connected. This mechanism is used to override the default navigation features of the browser.

◆ backward

void QTextBrowser::backward ( )
virtualslot

Changes the document displayed to the previous document in the list of documents built by navigating links.

Does nothing if there is no previous document.

See also
forward(), backwardAvailable()

Definition at line 915 of file qtextbrowser.cpp.

References backwardAvailable(), d, emit, forwardAvailable(), and historyChanged().

Referenced by keyPressEvent().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ backwardAvailable

void QTextBrowser::backwardAvailable ( bool available)
signal

This signal is emitted when the availability of backward() changes.

available is false when the user is at home(); otherwise it is true.

Referenced by backward(), clearHistory(), doSetSource(), and forward().

+ Here is the caller graph for this function:

◆ backwardHistoryCount()

int QTextBrowser::backwardHistoryCount ( ) const

Returns the number of locations backward in the history.

Since
4.4

Definition at line 1263 of file qtextbrowser.cpp.

References d.

◆ clearHistory()

void QTextBrowser::clearHistory ( )
Since
4.2

Clears the history of visited documents and disables the forward and backward navigation.

See also
backward(), forward()

Definition at line 1193 of file qtextbrowser.cpp.

References backwardAvailable(), d, emit, forwardAvailable(), historyChanged(), and QTextBrowserPrivate::HistoryEntry::url.

+ Here is the call graph for this function:

◆ doSetSource()

void QTextBrowser::doSetSource ( const QUrl & url,
QTextDocument::ResourceType type = QTextDocument::UnknownResource )
protectedvirtual

Attempts to load the document at the given url with the specified type.

setSource() calls doSetSource. In Qt 5, setSource(const QUrl &url) was virtual. In Qt 6, doSetSource() is virtual instead, so that it can be overridden in subclasses.

Definition at line 814 of file qtextbrowser.cpp.

References backwardAvailable(), d, QTextEdit::documentTitle, emit, forwardAvailable(), historyChanged(), QUrl::isValid(), url, and QTextBrowserPrivate::HistoryEntry::url.

Referenced by setSource().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ event()

bool QTextBrowser::event ( QEvent * e)
overrideprotectedvirtual

\reimp

Reimplemented from QTextEdit.

Definition at line 1317 of file qtextbrowser.cpp.

References QTextEdit::event().

+ Here is the call graph for this function:

◆ focusNextPrevChild()

bool QTextBrowser::focusNextPrevChild ( bool next)
overrideprotectedvirtual

\reimp

Reimplemented from QTextEdit.

Definition at line 1080 of file qtextbrowser.cpp.

References d, QTextEdit::focusNextPrevChild(), next, and url.

+ Here is the call graph for this function:

◆ focusOutEvent()

void QTextBrowser::focusOutEvent ( QFocusEvent * ev)
overrideprotectedvirtual

\reimp

Reimplemented from QTextEdit.

Definition at line 1068 of file qtextbrowser.cpp.

References d, QTextEdit::focusOutEvent(), Qt::IBeamCursor, and Qt::TextEditable.

+ Here is the call graph for this function:

◆ forward

void QTextBrowser::forward ( )
virtualslot

Changes the document displayed to the next document in the list of documents built by navigating links.

Does nothing if there is no next document.

See also
backward(), forwardAvailable()

Definition at line 937 of file qtextbrowser.cpp.

References backwardAvailable(), d, emit, forwardAvailable(), and historyChanged().

Referenced by keyPressEvent().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ forwardAvailable

void QTextBrowser::forwardAvailable ( bool available)
signal

This signal is emitted when the availability of forward() changes.

available is true after the user navigates backward() and false when the user navigates or goes forward().

Referenced by backward(), clearHistory(), doSetSource(), and forward().

+ Here is the caller graph for this function:

◆ forwardHistoryCount()

int QTextBrowser::forwardHistoryCount ( ) const

Returns the number of locations forward in the history.

Since
4.4

Definition at line 1252 of file qtextbrowser.cpp.

References d.

◆ highlighted

void QTextBrowser::highlighted ( const QUrl & link)
signal

This signal is emitted when the user has selected but not activated an anchor in the document.

The URL referred to by the anchor is passed in link.

◆ historyChanged

void QTextBrowser::historyChanged ( )
signal
Since
4.4

This signal is emitted when the history changes.

See also
historyTitle(), historyUrl()

Referenced by backward(), clearHistory(), doSetSource(), and forward().

+ Here is the caller graph for this function:

◆ historyTitle()

QString QTextBrowser::historyTitle ( int i) const

Returns the documentTitle() of the HistoryItem.

\table \header

backaction.setToolTip(browser.historyTitle(-1));
forwardaction.setToolTip(browser.historyTitle(+1));
Since
4.4

Definition at line 1240 of file qtextbrowser.cpp.

References d, and i.

◆ historyUrl()

QUrl QTextBrowser::historyUrl ( int i) const

Returns the url of the HistoryItem.

\table \header

Since
4.4

Definition at line 1220 of file qtextbrowser.cpp.

References d, and i.

◆ home

void QTextBrowser::home ( )
virtualslot

Changes the document displayed to be the first document from the history.

Definition at line 957 of file qtextbrowser.cpp.

References d, and setSource().

Referenced by keyPressEvent().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ isBackwardAvailable()

bool QTextBrowser::isBackwardAvailable ( ) const
Since
4.2

Returns true if the text browser can go backward in the document history using backward().

See also
backwardAvailable(), backward()

Definition at line 1165 of file qtextbrowser.cpp.

References d.

◆ isForwardAvailable()

bool QTextBrowser::isForwardAvailable ( ) const
Since
4.2

Returns true if the text browser can go forward in the document history using forward().

See also
forwardAvailable(), forward()

Definition at line 1179 of file qtextbrowser.cpp.

References d.

◆ keyPressEvent()

void QTextBrowser::keyPressEvent ( QKeyEvent * ev)
overrideprotectedvirtual

The event ev is used to provide the following keyboard shortcuts: \table \header.

Reimplemented from QTextEdit.

Definition at line 973 of file qtextbrowser.cpp.

References Qt::AltModifier, backward(), cursor, d, forward(), home(), Qt::Key_Back, Qt::Key_Down, Qt::Key_Left, Qt::Key_Right, Qt::Key_Select, Qt::Key_Up, and QTextEdit::keyPressEvent().

+ Here is the call graph for this function:

◆ loadResource()

QVariant QTextBrowser::loadResource ( int type,
const QUrl & name )
overridevirtual

This function is called when the document is loaded and for each image in the document.

The type indicates the type of resource to be loaded. An invalid QVariant is returned if the resource cannot be loaded.

The default implementation ignores type and tries to locate the resources by interpreting name as a file name. If it is not an absolute path it tries to find the file in the paths of the \l searchPaths property and in the same directory as the current source. On success, the result is a QVariant that stores a QByteArray with the contents of the file.

If you reimplement this function, you can return other QVariant types. The table below shows which variant types are supported depending on the resource type:

\table \header

Reimplemented from QTextEdit.

Definition at line 1138 of file qtextbrowser.cpp.

References d, fileName, and QIODeviceBase::ReadOnly.

◆ mouseMoveEvent()

void QTextBrowser::mouseMoveEvent ( QMouseEvent * ev)
overrideprotectedvirtual

\reimp

Reimplemented from QTextEdit.

Definition at line 1044 of file qtextbrowser.cpp.

References QTextEdit::mouseMoveEvent().

+ Here is the call graph for this function:

◆ mousePressEvent()

void QTextBrowser::mousePressEvent ( QMouseEvent * ev)
overrideprotectedvirtual

\reimp

Reimplemented from QTextEdit.

Definition at line 1052 of file qtextbrowser.cpp.

References QTextEdit::mousePressEvent().

+ Here is the call graph for this function:

◆ mouseReleaseEvent()

void QTextBrowser::mouseReleaseEvent ( QMouseEvent * ev)
overrideprotectedvirtual

\reimp

Reimplemented from QTextEdit.

Definition at line 1060 of file qtextbrowser.cpp.

References QTextEdit::mouseReleaseEvent().

+ Here is the call graph for this function:

◆ openExternalLinks()

bool QTextBrowser::openExternalLinks ( ) const

Definition at line 1280 of file qtextbrowser.cpp.

References d.

◆ openLinks()

bool QTextBrowser::openLinks ( ) const

Definition at line 1304 of file qtextbrowser.cpp.

References d.

◆ paintEvent()

void QTextBrowser::paintEvent ( QPaintEvent * e)
overrideprotectedvirtual

\reimp

Reimplemented from QTextEdit.

Definition at line 1106 of file qtextbrowser.cpp.

References d.

◆ reload

void QTextBrowser::reload ( )
virtualslot

Reloads the current set source.

Definition at line 785 of file qtextbrowser.cpp.

References d, and setSource().

+ Here is the call graph for this function:

◆ searchPaths()

QStringList QTextBrowser::searchPaths ( ) const

Definition at line 770 of file qtextbrowser.cpp.

References d.

◆ setOpenExternalLinks()

void QTextBrowser::setOpenExternalLinks ( bool open)

Definition at line 1286 of file qtextbrowser.cpp.

References d, and open().

+ Here is the call graph for this function:

◆ setOpenLinks()

void QTextBrowser::setOpenLinks ( bool open)

Definition at line 1310 of file qtextbrowser.cpp.

References d, and open().

+ Here is the call graph for this function:

◆ setSearchPaths()

void QTextBrowser::setSearchPaths ( const QStringList & paths)

Definition at line 776 of file qtextbrowser.cpp.

References d.

◆ setSource

void QTextBrowser::setSource ( const QUrl & url,
QTextDocument::ResourceType type = QTextDocument::UnknownResource )
slot

Attempts to load the document at the given url with the specified type.

If type is \l {QTextDocument::UnknownResource}{UnknownResource} (the default), the document type will be detected: that is, if the url ends with an extension of {.md}, {.mkd} or {.markdown}, the document will be loaded via \l QTextDocument::setMarkdown(); otherwise it will be loaded via \l QTextDocument::setHtml(). This detection can be bypassed by specifying the type explicitly.

Definition at line 803 of file qtextbrowser.cpp.

References doSetSource(), and url.

Referenced by home(), and reload().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ source()

QUrl QTextBrowser::source ( ) const

Definition at line 734 of file qtextbrowser.cpp.

References d.

◆ sourceChanged

void QTextBrowser::sourceChanged ( const QUrl & src)
signal

This signal is emitted when the source has changed, src being the new source.

Source changes happen both programmatically when calling setSource(), forward(), backward() or home() or when the user clicks on links or presses the equivalent key sequences.

◆ sourceType()

QTextDocument::ResourceType QTextBrowser::sourceType ( ) const

Definition at line 751 of file qtextbrowser.cpp.

References d, and QTextDocument::UnknownResource.

Property Documentation

◆ openExternalLinks

QTextBrowser::openExternalLinks
readwrite
Since
4.2

Specifies whether QTextBrowser should automatically open links to external sources using QDesktopServices::openUrl() instead of emitting the anchorClicked signal. Links are considered external if their scheme is neither file or qrc.

The default value is false.

Definition at line 27 of file qtextbrowser.h.

◆ openLinks

QTextBrowser::openLinks
readwrite
Since
4.3

This property specifies whether QTextBrowser should automatically open links the user tries to activate by mouse or keyboard.

Regardless of the value of this property the anchorClicked signal is always emitted.

The default value is true.

Definition at line 28 of file qtextbrowser.h.

◆ searchPaths

QTextBrowser::searchPaths
readwrite

the search paths used by the text browser to find supporting content

QTextBrowser uses this list to locate images and documents.

By default, this property contains an empty string list.

Definition at line 26 of file qtextbrowser.h.

◆ source

QTextBrowser::source
readwrite

the name of the displayed document.

This is a an invalid url if no document is displayed or if the source is unknown.

When setting this property QTextBrowser tries to find a document with the specified name in the paths of the searchPaths property and directory of the current source, unless the value is an absolute file path. It also checks for optional anchors and scrolls the document accordingly

If the first tag in the document is {<qt type=detail>>}, the document is displayed as a popup rather than as new document in the browser window itself. Otherwise, the document is displayed normally in the text browser with the text set to the contents of the named document with \l QTextDocument::setHtml() or \l QTextDocument::setMarkdown(), depending on whether the filename ends with any of the known Markdown file extensions.

If you would like to avoid automatic type detection and specify the type explicitly, call setSource() rather than setting this property.

By default, this property contains an empty URL.

Definition at line 21 of file qtextbrowser.h.

◆ sourceType

QTextBrowser::sourceType
read

the type of the displayed document

This is QTextDocument::UnknownResource if no document is displayed or if the type of the source is unknown. Otherwise it holds the type that was detected, or the type that was specified when setSource() was called.

Definition at line 22 of file qtextbrowser.h.


The documentation for this class was generated from the following files: