Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.trolltech.qt.gui
Class QTextBrowser

    java.lang.Object
      com.trolltech.qt.internal.QSignalEmitterInternal
          com.trolltech.qt.QSignalEmitter
              com.trolltech.qt.QtJambiObject
                  com.trolltech.qt.core.QObject
                      com.trolltech.qt.gui.QWidget
                          com.trolltech.qt.gui.QFrame
                              com.trolltech.qt.gui.QAbstractScrollArea
                                  com.trolltech.qt.gui.QTextEdit
                                      com.trolltech.qt.gui.QTextBrowser

All Implemented Interfaces:
  QPaintDeviceInterface, QtJambiInterface

    public class QTextBrowser

extends QTextEdit

The `QTextBrowser` class provides a rich text browser with hypertext navigation. 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`.

## 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.

## Navigation

`QTextBrowser` provides `backward()` and `forward()` slots which you can use to implement Back and Forward buttons. The `home()` slot sets the text to the very first document displayed. The `anchorClicked()` signal is emitted when the user clicks an anchor. To override the default navigation behavior of the browser, call the `setSource()` function to supply new document text in a slot connected to this signal.

If you want to load documents stored in the Qt resource system use `qrc` as the scheme in the URL to load. For example, for the document resource path `:/docs/index.html` use `qrc:/docs/index.html` as the URL with `setSource()`.

See also:
  `QTextEdit`, and `QTextDocument`.

Nested Class Summary

Nested classes/interfaces inherited from class com.trolltech.qt.gui.QTextEdit
`QTextEdit.AutoFormatting, QTextEdit.AutoFormattingFlag, QTextEdit.LineWrapMode`

Nested classes/interfaces inherited from class com.trolltech.qt.gui.QFrame
`QFrame.Shadow, QFrame.Shape, QFrame.StyleMask`

Nested classes/interfaces inherited from class com.trolltech.qt.gui.QWidget
`QWidget.RenderFlag, QWidget.RenderFlags`

Nested classes/interfaces inherited from class com.trolltech.qt.QSignalEmitter
`QSignalEmitter.AbstractSignal, QSignalEmitter.Signal0, QSignalEmitter.Signal1, QSignalEmitter.Signal2, QSignalEmitter.Signal3, QSignalEmitter.Signal4, QSignalEmitter.Signal5, QSignalEmitter.Signal6, QSignalEmitter.Signal7, QSignalEmitter.Signal8, QSignalEmitter.Signal9`

Nested classes/interfaces inherited from class com.trolltech.qt.internal.QSignalEmitterInternal
`com.trolltech.qt.internal.QSignalEmitterInternal.AbstractSignalInternal`

Field Summary
`QSignalEmitter.Signal1` | `anchorClicked` This signal takes 1 generic argument(s).
`QSignalEmitter.Signal1` | `backwardAvailable` This signal takes 1 generic argument(s).
`QSignalEmitter.Signal1` | `forwardAvailable` This signal takes 1 generic argument(s).
`QSignalEmitter.Signal1` | `highlighted` This signal takes 1 generic argument(s).
`QSignalEmitter.Signal1` | `highlightedString` This signal takes 1 generic argument(s).
`QSignalEmitter.Signal0` | `historyChanged` This signal is emitted when the history changes.
`QSignalEmitter.Signal1` | `sourceChanged` This signal takes 1 generic argument(s).

Fields inherited from class com.trolltech.qt.gui.QTextEdit
`copyAvailable, currentCharFormatChanged, cursorPositionChanged, redoAvailable, selectionChanged, textChanged, undoAvailable`

Fields inherited from class com.trolltech.qt.gui.QWidget
`customContextMenuRequested`

Fields inherited from class com.trolltech.qt.internal.QSignalEmitterInternal
`currentSender`

Constructor Summary
`QTextBrowser()` Constructs an empty `QTextBrowser` with parent `parent`.
`QTextBrowser(QWidget parent)` Constructs an empty `QTextBrowser` with parent `parent`.

Method Summary
`void` | `backward()` Changes the document displayed to the previous document in the list of documents built by navigating links.
`int` | `backwardHistoryCount()` Returns the number of locations backward in the history.
`void` | `clearHistory()` Clears the history of visited documents and disables the forward and backward navigation.
`void` | `forward()` Changes the document displayed to the next document in the list of documents built by navigating links.
`int` | `forwardHistoryCount()` Returns the number of locations forward in the history.
`java.lang.String` | `historyTitle(int arg__1)` Returns the documentTitle() of the HistoryItem.
`QUrl` | `historyUrl(int arg__1)` Returns the url of the HistoryItem.
`void` | `home()` Changes the document displayed to be the first document from the history.
`boolean` | `isBackwardAvailable()` Returns true if the text browser can go backward in the document history using `backward()`.
`boolean` | `isForwardAvailable()` Returns true if the text browser can go forward in the document history using `forward()`.
`boolean` | `openExternalLinks()` Specifies whether `QTextBrowser` should automatically open links to external sources using `QDesktopServices::openUrl()` instead of emitting the anchorClicked signal.
`boolean` | `openLinks()` This property specifies whether `QTextBrowser` should automatically open links the user tries to activate by mouse or keyboard.
`void` | `reload()` Reloads the current set source.
`java.util.List` | `searchPaths()` This property holds the search paths used by the text browser to find supporting content.
`void` | `setOpenExternalLinks(boolean open)` Specifies whether `QTextBrowser` should automatically open links to external sources using `QDesktopServices::openUrl()` instead of emitting the anchorClicked signal.
`void` | `setOpenLinks(boolean open)` This property specifies whether `QTextBrowser` should automatically open links the user tries to activate by mouse or keyboard.
`void` | `setSearchPaths(java.util.List paths)` This property holds the search paths used by the text browser to find supporting content.
`void` | `setSource(QUrl name)` This property holds the name of the displayed document.
`QUrl` | `source()` This property holds the name of the displayed document.

Methods inherited from class com.trolltech.qt.gui.QTextEdit
`acceptRichText, alignment, anchorAt, append, autoFormatting, canInsertFromMimeData, canPaste, clear, copy, createMimeDataFromSelection, createStandardContextMenu, createStandardContextMenu, currentCharFormat, currentFont, cursorForPosition, cursorRect, cursorRect, cursorWidth, cut, document, documentTitle, ensureCursorVisible, extraSelections, find, find, find, fontFamily, fontItalic, fontPointSize, fontUnderline, fontWeight, insertFromMimeData, insertHtml, insertPlainText, isReadOnly, isUndoRedoEnabled, lineWrapColumnOrWidth, lineWrapMode, loadResource, mergeCurrentCharFormat, moveCursor, moveCursor, overwriteMode, paste, print, redo, scrollToAnchor, selectAll, setAcceptRichText, setAlignment, setAlignment, setAutoFormatting, setAutoFormatting, setCurrentCharFormat, setCurrentFont, setCursorWidth, setDocument, setDocumentTitle, setExtraSelections, setFontFamily, setFontItalic, setFontPointSize, setFontUnderline, setFontWeight, setHtml, setLineWrapColumnOrWidth, setLineWrapMode, setOverwriteMode, setPlainText, setReadOnly, setTabChangesFocus, setTabStopWidth, setText, setTextBackgroundColor, setTextColor, setTextCursor, setTextInteractionFlags, setTextInteractionFlags, setUndoRedoEnabled, setWordWrapMode, tabChangesFocus, tabStopWidth, textBackgroundColor, textColor, textCursor, textInteractionFlags, toHtml, toPlainText, undo, wordWrapMode, zoomIn, zoomIn, zoomOut, zoomOut`

Methods inherited from class com.trolltech.qt.gui.QAbstractScrollArea
`addScrollBarWidget, addScrollBarWidget, cornerWidget, horizontalScrollBar, horizontalScrollBarPolicy, maximumViewportSize, scrollBarWidgets, scrollBarWidgets, scrollContentsBy, setCornerWidget, setHorizontalScrollBar, setHorizontalScrollBarPolicy, setupViewport, setVerticalScrollBar, setVerticalScrollBarPolicy, setViewport, setViewportMargins, verticalScrollBar, verticalScrollBarPolicy, viewport, viewportEvent`

Methods inherited from class com.trolltech.qt.gui.QFrame
`frameRect, frameShadow, frameShape, frameStyle, frameWidth, lineWidth, midLineWidth, setFrameRect, setFrameShadow, setFrameShape, setFrameStyle, setLineWidth, setMidLineWidth`

Methods inherited from class com.trolltech.qt.gui.QWidget
`acceptDrops, accessibleDescription, accessibleName, actionEvent, actions, activateWindow, addAction, addActions, adjustSize, autoFillBackground, backgroundRole, baseSize, changeEvent, childAt, childAt, childrenRect, childrenRegion, clearFocus, clearMask, close, closeEvent, contentsRect, contextMenuEvent, contextMenuPolicy, cursor, depth, destroy, destroy, destroy, dragEnterEvent, dragLeaveEvent, dragMoveEvent, dropEvent, effectiveWinId, ensurePolished, enterEvent, focusInEvent, focusNextChild, focusNextPrevChild, focusOutEvent, focusPolicy, focusPreviousChild, focusProxy, focusWidget, font, fontInfo, fontMetrics, foregroundRole, frameGeometry, frameSize, geometry, getContentsMargins, grabKeyboard, grabMouse, grabMouse, grabShortcut, grabShortcut, hasFocus, hasMouseTracking, height, heightForWidth, heightMM, hide, hideEvent, inputContext, inputMethodEvent, inputMethodQuery, insertAction, insertActions, isActiveWindow, isAncestorOf, isEnabled, isEnabledTo, isFullScreen, isHidden, isMaximized, isMinimized, isModal, isVisible, isVisibleTo, isWindow, isWindowModified, keyboardGrabber, keyPressEvent, keyReleaseEvent, languageChange, layout, layoutDirection, leaveEvent, locale, logicalDpiX, logicalDpiY, lower, mapFrom, mapFromGlobal, mapFromParent, mapTo, mapToGlobal, mapToParent, mask, maximumHeight, maximumSize, maximumWidth, metric, minimumHeight, minimumSize, minimumSizeHint, minimumWidth, mouseDoubleClickEvent, mouseGrabber, mouseMoveEvent, mousePressEvent, mouseReleaseEvent, move, move, moveEvent, nativeParentWidget, nextInFocusChain, normalGeometry, numColors, overrideWindowFlags, overrideWindowFlags, paintEngine, paintEvent, paintingActive, palette, parentWidget, physicalDpiX, physicalDpiY, pos, raise, rect, releaseKeyboard, releaseMouse, releaseShortcut, removeAction, render, render, render, render, render, render, render, render, render, repaint, repaint, repaint, repaint, resetInputContext, resize, resize, resizeEvent, restoreGeometry, saveGeometry, scroll, scroll, setAcceptDrops, setAccessibleDescription, setAccessibleName, setAttribute, setAttribute, setAutoFillBackground, setBackgroundRole, setBaseSize, setBaseSize, setContentsMargins, setContentsMargins, setContextMenuPolicy, setCursor, setDisabled, setEnabled, setFixedHeight, setFixedSize, setFixedSize, setFixedWidth, setFocus, setFocus, setFocusPolicy, setFocusProxy, setFont, setForegroundRole, setGeometry, setGeometry, setHidden, setInputContext, setLayout, setLayoutDirection, setLocale, setMask, setMask, setMaximumHeight, setMaximumSize, setMaximumSize, setMaximumWidth, setMinimumHeight, setMinimumSize, setMinimumSize, setMinimumWidth, setMouseTracking, setPalette, setParent, setParent, setParent, setShortcutAutoRepeat, setShortcutAutoRepeat, setShortcutEnabled, setShortcutEnabled, setSizeIncrement, setSizeIncrement, setSizePolicy, setSizePolicy, setStatusTip, setStyle, setStyleSheet, setTabOrder, setToolTip, setUpdatesEnabled, setVisible, setWhatsThis, setWindowFilePath, setWindowFlags, setWindowFlags, setWindowIcon, setWindowIconText, setWindowModality, setWindowModified, setWindowOpacity, setWindowRole, setWindowState, setWindowState, setWindowTitle, show, showEvent, showFullScreen, showMaximized, showMinimized, showNormal, size, sizeHint, sizeIncrement, sizePolicy, stackUnder, statusTip, style, styleSheet, tabletEvent, testAttribute, toolTip, underMouse, unsetCursor, unsetLayoutDirection, unsetLocale, update, update, update, update, updateGeometry, updateMicroFocus, updatesEnabled, visibleRegion, whatsThis, wheelEvent, width, widthMM, window, windowFilePath, windowFlags, windowIcon, windowIconText, windowModality, windowOpacity, windowRole, windowState, windowTitle, windowType, winId, x, y`

Methods inherited from class com.trolltech.qt.core.QObject
`childEvent, children, connectSlotsByName, customEvent, disposeLater, dumpObjectInfo, dumpObjectTree, dynamicPropertyNames, event, eventFilter, findChild, findChild, findChild, findChildren, findChildren, findChildren, findChildren, indexOfProperty, installEventFilter, isWidgetType, killTimer, moveToThread, objectName, parent, properties, property, removeEventFilter, setObjectName, setParent, setProperty, startTimer, timerEvent, toString, userProperty`

Methods inherited from class com.trolltech.qt.QtJambiObject
`dispose, disposed, equals, finalize, reassignNativeResources, tr, tr, tr`

Methods inherited from class com.trolltech.qt.QSignalEmitter
`blockSignals, disconnect, disconnect, signalsBlocked, signalSender, thread`

Methods inherited from class com.trolltech.qt.internal.QSignalEmitterInternal
`__qt_signalInitialization`

Methods inherited from class java.lang.Object
`clone, getClass, hashCode, notify, notifyAll, wait, wait, wait`

Methods inherited from interface com.trolltech.qt.QtJambiInterface
`disableGarbageCollection, nativeId, nativePointer, reenableGarbageCollection, setJavaOwnership`

Field Detail

### anchorClicked

    public final QSignalEmitter.Signal1 anchorClicked

  This signal takes 1 generic argument(s). We list their type and the name they go by in the description of this signal. <com.trolltech.qt.core.QUrl(named: link)>:

  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.

### backwardAvailable

    public final QSignalEmitter.Signal1 backwardAvailable

  This signal takes 1 generic argument(s). We list their type and the name they go by in the description of this signal. <java.lang.Boolean(named: available)>:

  This signal is emitted when the availability of `backward()` changes. `available` is false when the user is at `home()`; otherwise it is true.

### forwardAvailable

    public final QSignalEmitter.Signal1 forwardAvailable

  This signal takes 1 generic argument(s). We list their type and the name they go by in the description of this signal. <java.lang.Boolean(named: available)>:

  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()`.

### highlightedString

    public final QSignalEmitter.Signal1 highlightedString

  This signal takes 1 generic argument(s). We list their type and the name they go by in the description of this signal. <java.lang.String(named: link)>:

  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`.

### highlighted

    public final QSignalEmitter.Signal1 highlighted

  This signal takes 1 generic argument(s). We list their type and the name they go by in the description of this signal. <com.trolltech.qt.core.QUrl(named: link)>:

  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

    public final QSignalEmitter.Signal0 historyChanged

  This signal is emitted when the history changes.

See also:
  `historyTitle()`, and `historyUrl()`.

### sourceChanged

    public final QSignalEmitter.Signal1 sourceChanged

  This signal takes 1 generic argument(s). We list their type and the name they go by in the description of this signal. <com.trolltech.qt.core.QUrl(named: src)>:

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

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

Constructor Detail

### QTextBrowser

    public QTextBrowser()

  Constructs an empty `QTextBrowser` with parent `parent`.

### QTextBrowser

    public QTextBrowser(QWidget parent)

  Constructs an empty `QTextBrowser` with parent `parent`.

Method Detail

### backwardHistoryCount

    public final int backwardHistoryCount()

  Returns the number of locations backward in the history.

### clearHistory

    public final void clearHistory()

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

See also:
  `backward()`, and `forward()`.

### forwardHistoryCount

    public final int forwardHistoryCount()

  Returns the number of locations forward in the history.

### historyTitle

    public final java.lang.String historyTitle(int arg__1)

  Returns the documentTitle() of the HistoryItem.

  Input | Return
  --- | ---
  `i` < 0 | `backward()` history
  `i` == 0 | current, see `QTextBrowser::source()`
  `i` > 0 | `forward()` history

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

### historyUrl

    public final QUrl historyUrl(int arg__1)

  Returns the url of the HistoryItem.

  Input | Return
  --- | ---
  `i` < 0 | `backward()` history
  `i` == 0 | current, see `QTextBrowser::source()`
  `i` > 0 | `forward()` history

### isBackwardAvailable

    public final boolean isBackwardAvailable()

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

See also:
  `backwardAvailable()` , and `backward()`.

### isForwardAvailable

    public final boolean isForwardAvailable()

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

See also:
  `forwardAvailable()` , and `forward()`.

### openExternalLinks

    public final boolean openExternalLinks()

  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.

### openLinks

    public final boolean openLinks()

  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.

### searchPaths

    public final java.util.List searchPaths()

  This property holds 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.

### setOpenExternalLinks

    public final void setOpenExternalLinks(boolean open)

  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.

### setOpenLinks

    public final void setOpenLinks(boolean open)

  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.

### setSearchPaths

    public final void setSearchPaths(java.util.List paths)

  This property holds 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.

### source

    public final QUrl source()

  This property holds 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 setHtml().

  By default, this property contains an empty URL.

### backward

    public void backward()

  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()`, and `backwardAvailable()` .

### forward

    public void forward()

  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()`, and `forwardAvailable()` .

### home

    public void home()

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

### reload

    public void reload()

  Reloads the current set source.

### setSource

    public void setSource(QUrl name)

  This property holds 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 setHtml().

  By default, this property contains an empty URL.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD