~oif-team/ubuntu/natty/qt4-x11/xi2.1

« back to all changes in this revision

Viewing changes to doc/html/qtextbrowser.html

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-08-24 04:09:09 UTC
  • Revision ID: james.westby@ubuntu.com-20050824040909-xmxe9jfr4a0w5671
Tags: upstream-4.0.0
ImportĀ upstreamĀ versionĀ 4.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?xml version="1.0" encoding="iso-8859-1"?>
 
2
<!DOCTYPE html
 
3
    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
 
4
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
 
5
<!-- /tmp/qt-4.0.0-espenr-1119621036935/qt-x11-opensource-desktop-4.0.0/src/gui/widgets/qtextbrowser.cpp -->
 
6
<head>
 
7
    <title>Qt 4.0: QTextBrowser Class Reference</title>
 
8
    <style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm; }
 
9
a:link { color: #004faf; text-decoration: none }
 
10
a:visited { color: #672967; text-decoration: none }
 
11
td.postheader { font-family: sans-serif }
 
12
tr.address { font-family: sans-serif }
 
13
body { background: #ffffff; color: black; }</style>
 
14
</head>
 
15
<body>
 
16
<table border="0" cellpadding="0" cellspacing="0" width="100%">
 
17
<tr>
 
18
<td align="left" valign="top" width="32"><img src="images/qt-logo.png" align="left" width="32" height="32" border="0" /></td>
 
19
<td width="1">&nbsp;&nbsp;</td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a>&nbsp;&middot; <a href="classes.html"><font color="#004faf">All&nbsp;Classes</font></a>&nbsp;&middot; <a href="mainclasses.html"><font color="#004faf">Main&nbsp;Classes</font></a>&nbsp;&middot; <a href="annotated.html"><font color="#004faf">Annotated</font></a>&nbsp;&middot; <a href="groups.html"><font color="#004faf">Grouped&nbsp;Classes</font></a>&nbsp;&middot; <a href="functions.html"><font color="#004faf">Functions</font></a></td>
 
20
<td align="right" valign="top" width="230"><img src="images/trolltech-logo.png" align="right" width="203" height="32" border="0" /></td></tr></table><h1 align="center">QTextBrowser Class Reference</h1>
 
21
<p>The QTextBrowser class provides a rich text browser with hypertext navigation. <a href="#details">More...</a></p>
 
22
<pre>#include &lt;QTextBrowser&gt;</pre><p>Part of the <a href="qtgui.html">QtGui</a> module.</p>
 
23
<p>Inherits <a href="qtextedit.html">QTextEdit</a>.</p>
 
24
<ul>
 
25
<li><a href="qtextbrowser-members.html">List of all members, including inherited members</a></li>
 
26
<li><a href="qtextbrowser-qt3.html">Qt 3 support members</a></li>
 
27
</ul>
 
28
<a name="properties"></a>
 
29
<h3>Properties</h3>
 
30
<table width="100%" border="0" cellpadding="0" cellspacing="0">
 
31
<tr><td width="45%" valign="top"><ul>
 
32
<li><div class="fn"/><b><a href="qtextbrowser.html#modified-prop">modified</a></b> : const bool</li>
 
33
<li><div class="fn"/><b><a href="qtextbrowser.html#readOnly-prop">readOnly</a></b> : const bool</li>
 
34
<li><div class="fn"/><b><a href="qtextbrowser.html#searchPaths-prop">searchPaths</a></b> : QStringList</li>
 
35
</ul></td><td valign="top"><ul>
 
36
<li><div class="fn"/><b><a href="qtextbrowser.html#source-prop">source</a></b> : QUrl</li>
 
37
<li><div class="fn"/><b><a href="qtextbrowser.html#undoRedoEnabled-prop">undoRedoEnabled</a></b> : const bool</li>
 
38
</ul>
 
39
</td></tr>
 
40
</table>
 
41
<ul>
 
42
<li><div class="fn"/>9 properties inherited from <a href="qtextedit.html#properties">QTextEdit</a></li>
 
43
<li><div class="fn"/>2 properties inherited from <a href="qabstractscrollarea.html#properties">QAbstractScrollArea</a></li>
 
44
<li><div class="fn"/>6 properties inherited from <a href="qframe.html#properties">QFrame</a></li>
 
45
<li><div class="fn"/>52 properties inherited from <a href="qwidget.html#properties">QWidget</a></li>
 
46
<li><div class="fn"/>1 property inherited from <a href="qobject.html#properties">QObject</a></li>
 
47
</ul>
 
48
<a name="public-functions"></a>
 
49
<h3>Public Functions</h3>
 
50
<ul>
 
51
<li><div class="fn"/><b><a href="qtextbrowser.html#QTextBrowser">QTextBrowser</a></b> ( QWidget * <i>parent</i> = 0 )</li>
 
52
<li><div class="fn"/>virtual QVariant <b><a href="qtextbrowser.html#loadResource">loadResource</a></b> ( int <i>type</i>, const QUrl &amp; <i>name</i> )</li>
 
53
<li><div class="fn"/>QStringList <b><a href="qtextbrowser.html#searchPaths-prop">searchPaths</a></b> () const</li>
 
54
<li><div class="fn"/>void <b><a href="qtextbrowser.html#searchPaths-prop">setSearchPaths</a></b> ( const QStringList &amp; <i>paths</i> )</li>
 
55
<li><div class="fn"/>QUrl <b><a href="qtextbrowser.html#source-prop">source</a></b> () const</li>
 
56
</ul>
 
57
<ul>
 
58
<li><div class="fn"/>42 public functions inherited from <a href="qtextedit.html#public-functions">QTextEdit</a></li>
 
59
<li><div class="fn"/>8 public functions inherited from <a href="qabstractscrollarea.html#public-functions">QAbstractScrollArea</a></li>
 
60
<li><div class="fn"/>13 public functions inherited from <a href="qframe.html#public-functions">QFrame</a></li>
 
61
<li><div class="fn"/>183 public functions inherited from <a href="qwidget.html#public-functions">QWidget</a></li>
 
62
<li><div class="fn"/>28 public functions inherited from <a href="qobject.html#public-functions">QObject</a></li>
 
63
<li><div class="fn"/>10 public functions inherited from <a href="qpaintdevice.html#public-functions">QPaintDevice</a></li>
 
64
</ul>
 
65
<a name="public-slots"></a>
 
66
<h3>Public Slots</h3>
 
67
<ul>
 
68
<li><div class="fn"/>virtual void <b><a href="qtextbrowser.html#backward">backward</a></b> ()</li>
 
69
<li><div class="fn"/>virtual void <b><a href="qtextbrowser.html#forward">forward</a></b> ()</li>
 
70
<li><div class="fn"/>virtual void <b><a href="qtextbrowser.html#home">home</a></b> ()</li>
 
71
<li><div class="fn"/>virtual void <b><a href="qtextbrowser.html#reload">reload</a></b> ()</li>
 
72
<li><div class="fn"/>virtual void <b><a href="qtextbrowser.html#source-prop">setSource</a></b> ( const QUrl &amp; <i>name</i> )</li>
 
73
</ul>
 
74
<ul>
 
75
<li><div class="fn"/>20 public slots inherited from <a href="qtextedit.html#public-slots">QTextEdit</a></li>
 
76
<li><div class="fn"/>17 public slots inherited from <a href="qwidget.html#public-slots">QWidget</a></li>
 
77
<li><div class="fn"/>1 public slot inherited from <a href="qobject.html#public-slots">QObject</a></li>
 
78
</ul>
 
79
<a name="signals"></a>
 
80
<h3>Signals</h3>
 
81
<ul>
 
82
<li><div class="fn"/>void <b><a href="qtextbrowser.html#anchorClicked">anchorClicked</a></b> ( const QUrl &amp; <i>link</i> )</li>
 
83
<li><div class="fn"/>void <b><a href="qtextbrowser.html#backwardAvailable">backwardAvailable</a></b> ( bool <i>available</i> )</li>
 
84
<li><div class="fn"/>void <b><a href="qtextbrowser.html#forwardAvailable">forwardAvailable</a></b> ( bool <i>available</i> )</li>
 
85
<li><div class="fn"/>void <b><a href="qtextbrowser.html#highlighted">highlighted</a></b> ( const QUrl &amp; <i>link</i> )</li>
 
86
<li><div class="fn"/>void <b><a href="qtextbrowser.html#highlighted-2">highlighted</a></b> ( const QString &amp; <i>link</i> )</li>
 
87
<li><div class="fn"/>void <b><a href="qtextbrowser.html#sourceChanged">sourceChanged</a></b> ( const QUrl &amp; <i>src</i> )</li>
 
88
</ul>
 
89
<ul>
 
90
<li><div class="fn"/>7 signals inherited from <a href="qtextedit.html#signals">QTextEdit</a></li>
 
91
<li><div class="fn"/>1 signal inherited from <a href="qwidget.html#signals">QWidget</a></li>
 
92
<li><div class="fn"/>1 signal inherited from <a href="qobject.html#signals">QObject</a></li>
 
93
</ul>
 
94
<a name="protected-functions"></a>
 
95
<h3>Protected Functions</h3>
 
96
<ul>
 
97
<li><div class="fn"/>virtual void <b><a href="qtextbrowser.html#keyPressEvent">keyPressEvent</a></b> ( QKeyEvent * <i>ev</i> )</li>
 
98
</ul>
 
99
<ul>
 
100
<li><div class="fn"/>4 protected functions inherited from <a href="qtextedit.html#protected-functions">QTextEdit</a></li>
 
101
<li><div class="fn"/>17 protected functions inherited from <a href="qabstractscrollarea.html#protected-functions">QAbstractScrollArea</a></li>
 
102
<li><div class="fn"/>39 protected functions inherited from <a href="qwidget.html#protected-functions">QWidget</a></li>
 
103
<li><div class="fn"/>7 protected functions inherited from <a href="qobject.html#protected-functions">QObject</a></li>
 
104
</ul>
 
105
<h3>Additional Inherited Members</h3>
 
106
<ul>
 
107
<li><div class="fn"/>2 static public members inherited from <a href="qframe.html#static-public-members">QFrame</a></li>
 
108
<li><div class="fn"/>4 static public members inherited from <a href="qwidget.html#static-public-members">QWidget</a></li>
 
109
<li><div class="fn"/>4 static public members inherited from <a href="qobject.html#static-public-members">QObject</a></li>
 
110
</ul>
 
111
<a name="details"></a>
 
112
<hr />
 
113
<h2>Detailed Description</h2>
 
114
<p>The QTextBrowser class provides a rich text browser with hypertext navigation.</p>
 
115
<p>This class extends <a href="qtextedit.html">QTextEdit</a> (in read-only mode), adding some navigation functionality so that users can follow links in hypertext documents. The contents of <a href="qtextedit.html">QTextEdit</a> are set with <a href="qtextedit.html#html-prop">setHtml</a>() or <a href="qtextedit.html#setPlainText">setPlainText</a>(), but QTextBrowser also implements the <a href="qtextbrowser.html#source-prop">setSource</a>() function, making it possible to set the text to a named document. 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, &quot;<tt>#anchor&quot;</tt>), the text browser automatically scrolls to that position (using <a href="qtextedit.html#scrollToAnchor">scrollToAnchor</a>()). When the user clicks on a hyperlink, the browser will call <a href="qtextbrowser.html#source-prop">setSource</a>() itself with the link's <tt>href</tt> value as argument. You can track the current source by connecting to the <a href="qtextbrowser.html#sourceChanged">sourceChanged</a>() signal.</p>
 
116
<p>QTextBrowser provides <a href="qtextbrowser.html#backward">backward</a>() and <a href="qtextbrowser.html#forward">forward</a>() slots which you can use to implement Back and Forward buttons. The <a href="qtextbrowser.html#home">home</a>() slot sets the text to the very first document displayed. The <a href="qtextbrowser.html#anchorClicked">anchorClicked</a>() signal is emitted when the user clicks an anchor.</p>
 
117
<p>If you want to provide your users with editable rich text use <a href="qtextedit.html">QTextEdit</a>. If you want a text browser without hypertext navigation use <a href="qtextedit.html">QTextEdit</a>, and use <a href="qtextedit.html#readOnly-prop">QTextEdit::setReadOnly</a>() to disable editing. If you just need to display a small piece of rich text use <a href="qlabel.html">QLabel</a>.</p>
 
118
<hr />
 
119
<h2>Property Documentation</h2>
 
120
<h3 class="fn"><a name="modified-prop"></a>modified : const bool</h3>
 
121
<p>This property holds whether the contents of the text browser have been modified.</p>
 
122
<h3 class="fn"><a name="readOnly-prop"></a>readOnly : const bool</h3>
 
123
<p>This property holds whether the text browser is read-only.</p>
 
124
<h3 class="fn"><a name="searchPaths-prop"></a>searchPaths : <a href="qstringlist.html">QStringList</a></h3>
 
125
<p>This property holds the search paths used by the text browser to find supporting content.</p>
 
126
<p><a href="qtextbrowser.html">QTextBrowser</a> uses this list to locate images and documents.</p>
 
127
<p>Access functions:</p>
 
128
<ul>
 
129
<li><div class="fn"/><b>QStringList searchPaths () const</b></li>
 
130
<li><div class="fn"/><b>void setSearchPaths ( const QStringList &amp; <i>paths</i> )</b></li>
 
131
</ul>
 
132
<h3 class="fn"><a name="source-prop"></a>source : <a href="qurl.html">QUrl</a></h3>
 
133
<p>This property holds the name of the displayed document.</p>
 
134
<p>This is a an invalid url if no document is displayed or if the source is unknown.</p>
 
135
<p>When setting this property <a href="qtextbrowser.html">QTextBrowser</a> tries to find a document with the specified name in the paths of the <a href="qtextbrowser.html#searchPaths-prop">searchPaths</a> 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</p>
 
136
<p>If the first tag in the document is <tt>&lt;qt type=detail&gt;</tt>, 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 <a href="qtextedit.html#html-prop">setHtml</a>().</p>
 
137
<p>Access functions:</p>
 
138
<ul>
 
139
<li><div class="fn"/><b>QUrl source () const</b></li>
 
140
<li><div class="fn"/><b>virtual void setSource ( const QUrl &amp; <i>name</i> )</b></li>
 
141
</ul>
 
142
<h3 class="fn"><a name="undoRedoEnabled-prop"></a>undoRedoEnabled : const bool</h3>
 
143
<p>This property holds whether the text browser supports undo/redo operations.</p>
 
144
<hr />
 
145
<h2>Member Function Documentation</h2>
 
146
<h3 class="fn"><a name="QTextBrowser"></a>QTextBrowser::QTextBrowser ( <a href="qwidget.html">QWidget</a> * <i>parent</i> = 0 )</h3>
 
147
<p>Constructs an empty <a href="qtextbrowser.html">QTextBrowser</a> with parent <i>parent</i>.</p>
 
148
<h3 class="fn"><a name="anchorClicked"></a>void QTextBrowser::anchorClicked ( const <a href="qurl.html">QUrl</a> &amp; <i>link</i> )&nbsp;&nbsp;<tt> [signal]</tt></h3>
 
149
<p>This signal is emitted when the user clicks an anchor. The URL referred to by the anchor is passed in <i>link</i>.</p>
 
150
<h3 class="fn"><a name="backward"></a>void QTextBrowser::backward ()&nbsp;&nbsp;<tt> [virtual slot]</tt></h3>
 
151
<p>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.</p>
 
152
<p>See also <a href="qtextbrowser.html#forward">forward</a>() and <a href="qtextbrowser.html#backwardAvailable">backwardAvailable</a>().</p>
 
153
<h3 class="fn"><a name="backwardAvailable"></a>void QTextBrowser::backwardAvailable ( bool <i>available</i> )&nbsp;&nbsp;<tt> [signal]</tt></h3>
 
154
<p>This signal is emitted when the availability of <a href="qtextbrowser.html#backward">backward</a>() changes. <i>available</i> is false when the user is at <a href="qtextbrowser.html#home">home</a>(); otherwise it is true.</p>
 
155
<h3 class="fn"><a name="forward"></a>void QTextBrowser::forward ()&nbsp;&nbsp;<tt> [virtual slot]</tt></h3>
 
156
<p>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.</p>
 
157
<p>See also <a href="qtextbrowser.html#backward">backward</a>() and <a href="qtextbrowser.html#forwardAvailable">forwardAvailable</a>().</p>
 
158
<h3 class="fn"><a name="forwardAvailable"></a>void QTextBrowser::forwardAvailable ( bool <i>available</i> )&nbsp;&nbsp;<tt> [signal]</tt></h3>
 
159
<p>This signal is emitted when the availability of <a href="qtextbrowser.html#forward">forward</a>() changes. <i>available</i> is true after the user navigates <a href="qtextbrowser.html#backward">backward</a>() and false when the user navigates or goes <a href="qtextbrowser.html#forward">forward</a>().</p>
 
160
<h3 class="fn"><a name="highlighted"></a>void QTextBrowser::highlighted ( const <a href="qurl.html">QUrl</a> &amp; <i>link</i> )&nbsp;&nbsp;<tt> [signal]</tt></h3>
 
161
<p>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 <i>link</i>.</p>
 
162
<h3 class="fn"><a name="highlighted-2"></a>void QTextBrowser::highlighted ( const <a href="qstring.html">QString</a> &amp; <i>link</i> )&nbsp;&nbsp;<tt> [signal]</tt></h3>
 
163
<p>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.</p>
 
164
<p>Convenience signal that allows connecting to a slot that takes just a <a href="qstring.html">QString</a>, like for example <a href="qstatusbar.html">QStatusBar</a>'s message().</p>
 
165
<h3 class="fn"><a name="home"></a>void QTextBrowser::home ()&nbsp;&nbsp;<tt> [virtual slot]</tt></h3>
 
166
<p>Changes the document displayed to be the first document the browser displayed.</p>
 
167
<h3 class="fn"><a name="keyPressEvent"></a>void QTextBrowser::keyPressEvent ( <a href="qkeyevent.html">QKeyEvent</a> * <i>ev</i> )&nbsp;&nbsp;<tt> [virtual protected]</tt></h3>
 
168
<p>The event <i>ev</i> is used to provide the following keyboard shortcuts:</p>
 
169
<table align="center" cellpadding="2" cellspacing="1" border="0">
 
170
<tr valign="top" bgcolor="#a2c511"><th>Keypress</th><th>Action</th></tr>
 
171
<tr valign="top" bgcolor="#f0f0f0"><td>Alt+Left Arrow</td><td><a href="qtextbrowser.html#backward">backward</a>()</td></tr>
 
172
<tr valign="top" bgcolor="#e0e0e0"><td>Alt+Right Arrow</td><td><a href="qtextbrowser.html#forward">forward</a>()</td></tr>
 
173
<tr valign="top" bgcolor="#f0f0f0"><td>Alt+Up Arrow</td><td><a href="qtextbrowser.html#home">home</a>()</td></tr>
 
174
</table>
 
175
<p>Reimplemented from <a href="qwidget.html#keyPressEvent">QWidget</a>.</p>
 
176
<h3 class="fn"><a name="loadResource"></a><a href="qvariant.html">QVariant</a> QTextBrowser::loadResource ( int <i>type</i>, const <a href="qurl.html">QUrl</a> &amp; <i>name</i> )&nbsp;&nbsp;<tt> [virtual]</tt></h3>
 
177
<p>This function is called when the document is loaded. The <i>type</i> indicates the type of resource to be loaded. For each image in the document, this function is called once.</p>
 
178
<p>The default implementation ignores <i>type</i> and tries to locate the resources by interpreting <i>name</i> as a file name. If it is not an absolute path it tries to find the file in the paths of the <a href="qtextbrowser.html#searchPaths-prop">searchPaths</a> property and in the same directory as the current source. On success, the result is a <a href="qvariant.html">QVariant</a> that stores a <a href="qbytearray.html">QByteArray</a> with the contents of the file.</p>
 
179
<p>If you reimplement this function, you can return other <a href="qvariant.html">QVariant</a> types. The table below shows which variant types are supported depending on the resource type:</p>
 
180
<table align="center" cellpadding="2" cellspacing="1" border="0">
 
181
<tr valign="top" bgcolor="#a2c511"><th>ResourceType</th><th><a href="qvariant.html#Type-enum">QVariant::Type</a></th></tr>
 
182
<tr valign="top" bgcolor="#f0f0f0"><td><a href="qtextdocument.html#ResourceType-enum">QTextDocument::HtmlResource</a></td><td><a href="qstring.html">QString</a> or <a href="qbytearray.html">QByteArray</a></td></tr>
 
183
<tr valign="top" bgcolor="#e0e0e0"><td><a href="qtextdocument.html#ResourceType-enum">QTextDocument::ImageResource</a></td><td><a href="qimage.html">QImage</a>, <a href="qpixmap.html">QPixmap</a> or <a href="qbytearray.html">QByteArray</a></td></tr>
 
184
</table>
 
185
<p>Reimplemented from <a href="qtextedit.html#loadResource">QTextEdit</a>.</p>
 
186
<h3 class="fn"><a name="reload"></a>void QTextBrowser::reload ()&nbsp;&nbsp;<tt> [virtual slot]</tt></h3>
 
187
<p>Reloads the current set source.</p>
 
188
<h3 class="fn"><a name="sourceChanged"></a>void QTextBrowser::sourceChanged ( const <a href="qurl.html">QUrl</a> &amp; <i>src</i> )&nbsp;&nbsp;<tt> [signal]</tt></h3>
 
189
<p>This signal is emitted when the source has changed, <i>src</i> being the new source.</p>
 
190
<p>Source changes happen both programmatically when calling <a href="qtextbrowser.html#source-prop">setSource</a>(), <a href="qtextbrowser.html#forward">forward</a>(), backword() or <a href="qtextbrowser.html#home">home</a>() or when the user clicks on links or presses the equivalent key sequences.</p>
 
191
<p /><address><hr /><div align="center">
 
192
<table width="100%" cellspacing="0" border="0"><tr class="address">
 
193
<td width="30%">Copyright &copy; 2005 <a href="trolltech.html">Trolltech</a></td>
 
194
<td width="40%" align="center"><a href="trademarks.html">Trademarks</a></td>
 
195
<td width="30%" align="right"><div align="right">Qt 4.0.0</div></td>
 
196
</tr></table></div></address></body>
 
197
</html>