summaryrefslogtreecommitdiffstats
path: root/doc/html/qtextbrowser.html
blob: c8deb9118d2ef9225a0f0ee66754b9fe875e0929 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/src/widgets/qtextbrowser.cpp:59 -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>QTextBrowser Class</title>
<style type="text/css"><!--
fn { margin-left: 1cm; text-indent: -1cm; }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }
body { background: #ffffff; color: black; }
--></style>
</head>
<body>

<table border="0" cellpadding="0" cellspacing="0" width="100%">
<tr bgcolor="#E5E5E5">
<td valign=center>
 <a href="index.html">
<font color="#004faf">Home</font></a>
 | <a href="classes.html">
<font color="#004faf">All&nbsp;Classes</font></a>
 | <a href="mainclasses.html">
<font color="#004faf">Main&nbsp;Classes</font></a>
 | <a href="annotated.html">
<font color="#004faf">Annotated</font></a>
 | <a href="groups.html">
<font color="#004faf">Grouped&nbsp;Classes</font></a>
 | <a href="functions.html">
<font color="#004faf">Functions</font></a>
</td>
<td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>QTextBrowser Class Reference</h1>

<p>The QTextBrowser class provides a rich text browser with hypertext navigation.
<a href="#details">More...</a>
<p><tt>#include &lt;<a href="qtextbrowser-h.html">qtextbrowser.h</a>&gt;</tt>
<p>Inherits <a href="qtextedit.html">QTextEdit</a>.
<p><a href="qtextbrowser-members.html">List of all member functions.</a>
<h2>Public Members</h2>
<ul>
<li class=fn><a href="#QTextBrowser"><b>QTextBrowser</b></a> ( QWidget&nbsp;*&nbsp;parent = 0, const&nbsp;char&nbsp;*&nbsp;name = 0 )</li>
<li class=fn>QString <a href="#source"><b>source</b></a> () const</li>
</ul>
<h2>Public Slots</h2>
<ul>
<li class=fn>virtual void <a href="#setSource"><b>setSource</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;name )</li>
<li class=fn>virtual void <a href="#backward"><b>backward</b></a> ()</li>
<li class=fn>virtual void <a href="#forward"><b>forward</b></a> ()</li>
<li class=fn>virtual void <a href="#home"><b>home</b></a> ()</li>
<li class=fn>virtual void <a href="#reload"><b>reload</b></a> ()</li>
</ul>
<h2>Signals</h2>
<ul>
<li class=fn>void <a href="#backwardAvailable"><b>backwardAvailable</b></a> ( bool&nbsp;available )</li>
<li class=fn>void <a href="#forwardAvailable"><b>forwardAvailable</b></a> ( bool&nbsp;available )</li>
<li class=fn>void <a href="#sourceChanged"><b>sourceChanged</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;src )</li>
<li class=fn>void <a href="#highlighted"><b>highlighted</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;link )</li>
<li class=fn>void <a href="#linkClicked"><b>linkClicked</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;link )</li>
<li class=fn>void <a href="#anchorClicked"><b>anchorClicked</b></a> ( const&nbsp;QString&nbsp;&amp;&nbsp;name, const&nbsp;QString&nbsp;&amp;&nbsp;link )</li>
</ul>
<h2>Properties</h2>
<ul>
<li class=fn>bool <a href="#modified-prop"><b>modified</b></a>&nbsp;- whether the contents have been modified &nbsp;<em>(read only)</em></li>
<li class=fn>bool <a href="#overwriteMode-prop"><b>overwriteMode</b></a>&nbsp;- this text browser's overwrite mode &nbsp;<em>(read only)</em></li>
<li class=fn>bool <a href="#readOnly-prop"><b>readOnly</b></a>&nbsp;- whether the contents are read only &nbsp;<em>(read only)</em></li>
<li class=fn>QString <a href="#source-prop"><b>source</b></a>&nbsp;- the name of the displayed document</li>
<li class=fn>int <a href="#undoDepth-prop"><b>undoDepth</b></a>&nbsp;- this text browser's undo depth &nbsp;<em>(read only)</em></li>
<li class=fn>bool <a href="#undoRedoEnabled-prop"><b>undoRedoEnabled</b></a>&nbsp;- whether undo and redo are enabled &nbsp;<em>(read only)</em></li>
</ul>
<h2>Protected Members</h2>
<ul>
<li class=fn>virtual void <a href="#keyPressEvent"><b>keyPressEvent</b></a> ( QKeyEvent&nbsp;*&nbsp;e )</li>
</ul>
<hr><a name="details"></a><h2>Detailed Description</h2>


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



<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 QTextEdit is set with
<a href="qtextedit.html#setText">setText</a>(), but QTextBrowser has an additional function,
<a href="#setSource">setSource</a>(), which makes it possible to set the text to a named
document. The name is looked up in the text view's mime source
factory. If a document name ends with an anchor (for example, "<tt>#anchor"</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 setSource() itself, with the link's <tt>href</tt>
value as argument. You can track the current source by connetion
to the <a href="#sourceChanged">sourceChanged</a>() signal.
<p> QTextBrowser provides <a href="#backward">backward</a>() and <a href="#forward">forward</a>() slots which you can
use to implement Back and Forward buttons. The <a href="#home">home</a>() slot sets
the text to the very first document displayed. The <a href="#linkClicked">linkClicked</a>()
signal is emitted when the user clicks a link.
<p> By using <a href="qtextedit.html#setMimeSourceFactory">QTextEdit::setMimeSourceFactory</a>() you can provide your
own subclass of <a href="qmimesourcefactory.html">QMimeSourceFactory</a>. This makes it possible to
access data from anywhere, for example from a network or from a
database. See <a href="qmimesourcefactory.html#data">QMimeSourceFactory::data</a>() for details.
<p> If you intend using 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:
<pre>
    <a href="qtextedit.html#mimeSourceFactory">mimeSourceFactory</a>()-&gt;setExtensionType("qml", "text/utf8");
    </pre>
 
This is to ensure that the factory is able to resolve the document
names.
<p> QTextBrowser interprets the tags it processes in accordance with
the default style sheet. Change the style sheet with
<a href="qtextedit.html#setStyleSheet">setStyleSheet</a>(); see <a href="qstylesheet.html">QStyleSheet</a> for details.
<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 QTextEdit, and use <a href="qtextedit.html#setReadOnly">QTextEdit::setReadOnly</a>() to disable
editing. If you just need to display a small piece of rich text
use <a href="qsimplerichtext.html">QSimpleRichText</a> or <a href="qlabel.html">QLabel</a>.
<p> <img src=qtextbrowser-m.png> <img src=qtextbrowser-w.png>
<p>See also <a href="advanced.html">Advanced Widgets</a>, <a href="helpsystem.html">Help System</a>, and <a href="text.html">Text Related Classes</a>.

<hr><h2>Member Function Documentation</h2>
<h3 class=fn><a name="QTextBrowser"></a>QTextBrowser::QTextBrowser ( <a href="qwidget.html">QWidget</a>&nbsp;*&nbsp;parent = 0, const&nbsp;char&nbsp;*&nbsp;name = 0 )
</h3>
Constructs an empty QTextBrowser called <em>name</em>, with parent <em>parent</em>.

<h3 class=fn>void <a name="anchorClicked"></a>QTextBrowser::anchorClicked ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;name, const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;link )<tt> [signal]</tt>
</h3>

<p> This signal is emitted when the user clicks an anchor. The <em>link</em> is
the value of the <tt>href</tt> i.e. the name of the target document.  The <em>name</em>
is the name of the anchor.
<p> <p>See also <a href="#linkClicked">linkClicked</a>().

<h3 class=fn>void <a name="backward"></a>QTextBrowser::backward ()<tt> [virtual slot]</tt>
</h3>
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> <p>See also <a href="#forward">forward</a>() and <a href="#backwardAvailable">backwardAvailable</a>().

<p>Example: <a href="helpviewer-example.html#x1019">helpviewer/helpwindow.cpp</a>.
<h3 class=fn>void <a name="backwardAvailable"></a>QTextBrowser::backwardAvailable ( bool&nbsp;available )<tt> [signal]</tt>
</h3>

<p> This signal is emitted when the availability of <a href="#backward">backward</a>()
changes. <em>available</em> is FALSE when the user is at <a href="#home">home</a>();
otherwise it is TRUE.

<p>Example: <a href="helpviewer-example.html#x1020">helpviewer/helpwindow.cpp</a>.
<h3 class=fn>void <a name="forward"></a>QTextBrowser::forward ()<tt> [virtual slot]</tt>
</h3>
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> <p>See also <a href="#backward">backward</a>() and <a href="#forwardAvailable">forwardAvailable</a>().

<p>Example: <a href="helpviewer-example.html#x1021">helpviewer/helpwindow.cpp</a>.
<h3 class=fn>void <a name="forwardAvailable"></a>QTextBrowser::forwardAvailable ( bool&nbsp;available )<tt> [signal]</tt>
</h3>

<p> This signal is emitted when the availability of <a href="#forward">forward</a>() changes.
<em>available</em> is TRUE after the user navigates <a href="#backward">backward</a>() and FALSE
when the user navigates or goes forward().

<p>Example: <a href="helpviewer-example.html#x1022">helpviewer/helpwindow.cpp</a>.
<h3 class=fn>void <a name="highlighted"></a>QTextBrowser::highlighted ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;link )<tt> [signal]</tt>
</h3>  
<p> This signal is emitted when the user has selected but not
activated a link in the document. <em>link</em> is the value of the <tt>href</tt> i.e. the name of the target document.

<p>Example: <a href="helpviewer-example.html#x1023">helpviewer/helpwindow.cpp</a>.
<h3 class=fn>void <a name="home"></a>QTextBrowser::home ()<tt> [virtual slot]</tt>
</h3>
Changes the document displayed to be the first document the
browser displayed.

<p>Example: <a href="helpviewer-example.html#x1024">helpviewer/helpwindow.cpp</a>.
<h3 class=fn>void <a name="keyPressEvent"></a>QTextBrowser::keyPressEvent ( <a href="qkeyevent.html">QKeyEvent</a>&nbsp;*&nbsp;e )<tt> [virtual protected]</tt>
</h3>
The event <em>e</em> is used to provide the following keyboard shortcuts:
<center><table cellpadding="4" cellspacing="2" border="0">
<tr bgcolor="#a2c511"> <th valign="top">Keypress	    <th valign="top">Action
<tr bgcolor="#f0f0f0"> <td valign="top">Alt+Left Arrow  <td valign="top"><a href="#backward">backward</a>()
<tr bgcolor="#d0d0d0"> <td valign="top">Alt+Right Arrow <td valign="top"><a href="#forward">forward</a>()
<tr bgcolor="#f0f0f0"> <td valign="top">Alt+Up Arrow    <td valign="top"><a href="#home">home</a>()
</table></center>

<p>Reimplemented from <a href="qtextedit.html#keyPressEvent">QTextEdit</a>.
<h3 class=fn>void <a name="linkClicked"></a>QTextBrowser::linkClicked ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;link )<tt> [signal]</tt>
</h3>

<p> This signal is emitted when the user clicks a link. The <em>link</em> is
the value of the <tt>href</tt> i.e. the name of the target document.
<p> The <em>link</em> will be the absolute location of the document, based
on the value of the anchor's href tag and the current context of
the document.
<p> <p>See also <a href="#anchorClicked">anchorClicked</a>() and <a href="qtextedit.html#context">context</a>().

<h3 class=fn>void <a name="reload"></a>QTextBrowser::reload ()<tt> [virtual slot]</tt>
</h3>
Reloads the current set source.

<h3 class=fn>void <a name="setSource"></a>QTextBrowser::setSource ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;name )<tt> [virtual slot]</tt>
</h3><p>Sets the name of the displayed document to <em>name</em>.
See the <a href="qtextbrowser.html#source-prop">"source"</a> property for details.
<h3 class=fn><a href="qstring.html">QString</a> <a name="source"></a>QTextBrowser::source () const
</h3><p>Returns the name of the displayed document.
See the <a href="qtextbrowser.html#source-prop">"source"</a> property for details.
<h3 class=fn>void <a name="sourceChanged"></a>QTextBrowser::sourceChanged ( const&nbsp;<a href="qstring.html">QString</a>&nbsp;&amp;&nbsp;src )<tt> [signal]</tt>
</h3>

<p> This signal is emitted when the mime source has changed, <em>src</em>
being the new source.
<p> Source changes happen both programmatically when calling
<a href="#setSource">setSource</a>(), <a href="#forward">forward</a>(), backword() or <a href="#home">home</a>() or when the user
clicks on links or presses the equivalent key sequences.

<p>Example: <a href="helpviewer-example.html#x1027">helpviewer/helpwindow.cpp</a>.
<hr><h2>Property Documentation</h2>
<h3 class=fn>bool <a name="modified-prop"></a>modified</h3>
<p>This property holds whether the contents have been modified.
<p>
<p><h3 class=fn>bool <a name="overwriteMode-prop"></a>overwriteMode</h3>
<p>This property holds this text browser's overwrite mode.
<p>
<p><h3 class=fn>bool <a name="readOnly-prop"></a>readOnly</h3>
<p>This property holds whether the contents are read only.
<p>
<p><h3 class=fn><a href="qstring.html">QString</a> <a name="source-prop"></a>source</h3>
<p>This property holds the name of the displayed document.
<p>This is a <a href="qstring.html#QString-null">QString::null</a> if no document is displayed or if the
source is unknown.
<p> Setting this property uses the <a href="qtextedit.html#mimeSourceFactory">mimeSourceFactory</a>() to lookup the
named document. It also checks for optional anchors and scrolls
the document accordingly.
<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#setText">setText</a>().
<p> If you are using the filesystem access capabilities of the mime
source factory, you must ensure that the factory knows about the
encoding of specified files; otherwise no data will be available.
The default factory handles a couple of common file extensions
such as <tt>*.html</tt> and <tt>*.txt</tt> with reasonable defaults. See
<a href="qmimesourcefactory.html#data">QMimeSourceFactory::data</a>() for details.

<p>Set this property's value with <a href="#setSource">setSource</a>() and get this property's value with <a href="#source">source</a>().
<h3 class=fn>int <a name="undoDepth-prop"></a>undoDepth</h3>
<p>This property holds this text browser's undo depth.
<p>
<p><h3 class=fn>bool <a name="undoRedoEnabled-prop"></a>undoRedoEnabled</h3>
<p>This property holds whether undo and redo are enabled.
<p>
<p><!-- eof -->
<hr><p>
This file is part of the <a href="index.html">Qt toolkit</a>.
Copyright &copy; 1995-2007
<a href="http://www.trolltech.com/">Trolltech</a>. All Rights Reserved.<p><address><hr><div align=center>
<table width=100% cellspacing=0 border=0><tr>
<td>Copyright &copy; 2007
<a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
<td align=right><div align=right>Qt 3.3.8</div>
</table></div></address></body>
</html>