A rich text browser with simple navigation. More...
#include <qtextbrowser.h>
Inherits QTextView.
Type | Name | READ | WRITE | Options |
---|---|---|---|---|
QString | source | source | setSource |
This class is the same as the QTextView it inherits, with the
addition that it provides basic navigation features to follow links
in hypertext documents that link to other rich text documents. While
QTextView only allows to set its contents with setText(),
QTextBrowser has an additional function setSource(), that makes it
possible to set documents by name. These names are looked up in the
text view's mime source factory. If a document name ends with an
anchor, for example "#anchor",
the text browser will
automatically scroll accordingly ( using scrollToAnchor() ). When
the user clicks on a hyperlink, the browser will call setSource()
itself, with the link's href
value as argument.
QTextBrowser doesn't provide actual Back and Forward buttons, but it has backward() and forward() slots that implement the functionality. The home() slots brings it back to its very first document displayed.
By using QTextView::setMimeSourceFactory(), you can provide your own subclass of QMimeSourceFactory. This makes it possible to access data from anywhere you need to, may it be the network or a database. See QMimeSourceFactory::data() for details.
If you intend to use the mime factory to read the data directly from the file system, you may have to specify the encoding for the file extension you are using. For example
mimeSourceFactory()->setExtensionType("qml", "text/utf8");
Otherwise, the factory will not be able to resolve the document names.
For simpler richt text use, see QLabel, QTextView or QSimpleRichText.
Constructs an empty QTextBrowser.
Destructs the browser.
[virtual slot]
Changes the document displayed to be the previous document in the list of documents build by navigating links.
See also forward() and backwardAvailable().
[signal]
This signal is emitted when the availability of the backward() changes. It becomes available when the user navigates forward, and unavailable when the user is at the home().
[virtual slot]
Changes the document displayed to be the next document in the list of documents build by navigating links.
See also backward() and forwardAvailable().
[signal]
This signal is emitted when the availability of the forward() changes. It becomes available after backward() is activated, and unavailable when the user navigates or goes forward() to the last navigated document.
[signal]
This signal is emitted when the user has selected but not activated a link in the document. href is the value of the href tag in the link.
[virtual slot]
Changes the document displayed to be the first document the browser displayed.
[virtual protected]
Add Backward and Forward on ALT-Left and ALT-Right respectively.
Reimplemented from QWidget.
Scrolls the browser so that the part of the document named name is at the top of the view (or as close to the top as the size of the document allows).
[virtual]
Sets the text document with the given name to be displayed. The name is looked up in the mimeSourceFactory() of the browser.
In addition to the factory lookup, this functions also checks for optional anchors and scrolls the document accordingly.
If the first tag in the document is <qt type=detail>,
it is
displayed as a popup rather than as new document in the browser
window itself. Otherwise, the document is set normally via
setText(), with name as new context.
If you are using the filesystem access capabilities of the mime
source factory, you have to ensure that the factory knows about the
encoding of specified text files, otherwise no data will be
available. The default factory handles a couple of common file
extensions such as *.html
and *.txt
with reasonable defaults. See
QMimeSourceFactory::data() for details.
[virtual]
Sets the contents of the browser to text, and emits the textChanged() signal.
Reimplemented from QTextView.
[virtual protected]
Reimplemented for internal reasons; the API is not affected.
Reimplemented from QWidget.
Returns the source of the currently display document. If no document is displayed or the source is unknown, a null string is returned.
See also setSource().
[signal]
This signal is emitted whenever the setText() changes the contents (eg. because the user clicked on a link).
[virtual protected]
Activate to emit highlighted().
Reimplemented from QScrollView.
[virtual protected]
override to press anchors.
Reimplemented from QScrollView.
[virtual protected]
override to activate anchors.
Reimplemented from QScrollView.
Search the documentation, FAQ, qt-interest archive and more (uses
www.trolltech.com):
This file is part of the Qt toolkit, copyright © 1995-2000 Trolltech, all rights reserved.
Copyright İ 2000 Trolltech | Trademarks | Qt version 2.2.1
|