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

« back to all changes in this revision

Viewing changes to doc/html/q3textbrowser.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/qt3support/text/q3textbrowser.cpp -->
 
6
<head>
 
7
    <title>Qt 4.0: Q3TextBrowser 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">Q3TextBrowser Class Reference</h1>
 
21
<p>The Q3TextBrowser class provides a rich text browser with hypertext navigation. <a href="#details">More...</a></p>
 
22
<pre>#include &lt;Q3TextBrowser&gt;</pre><p><b>This class is part of the Qt 3 support library.</b> It is provided to keep old source code working. We strongly advise against using it in new code. See the <a href="porting4.html">Porting Guide</a> for more information.</p>
 
23
<p>Part of the <a href="qt3support.html">Qt3Support</a> module.</p>
 
24
<p>Inherits <a href="q3textedit.html">Q3TextEdit</a>.</p>
 
25
<ul>
 
26
<li><a href="q3textbrowser-members.html">List of all members, including inherited members</a></li>
 
27
</ul>
 
28
<a name="properties"></a>
 
29
<h3>Properties</h3>
 
30
<ul>
 
31
<li><div class="fn"/><b><a href="q3textbrowser.html#source-prop">source</a></b> : QString</li>
 
32
</ul>
 
33
<ul>
 
34
<li><div class="fn"/>19 properties inherited from <a href="q3textedit.html#properties">Q3TextEdit</a></li>
 
35
<li><div class="fn"/>10 properties inherited from <a href="q3scrollview.html#properties">Q3ScrollView</a></li>
 
36
<li><div class="fn"/>2 properties inherited from <a href="q3frame.html#properties">Q3Frame</a></li>
 
37
<li><div class="fn"/>6 properties inherited from <a href="qframe.html#properties">QFrame</a></li>
 
38
<li><div class="fn"/>52 properties inherited from <a href="qwidget.html#properties">QWidget</a></li>
 
39
<li><div class="fn"/>1 property inherited from <a href="qobject.html#properties">QObject</a></li>
 
40
</ul>
 
41
<a name="public-functions"></a>
 
42
<h3>Public Functions</h3>
 
43
<ul>
 
44
<li><div class="fn"/><b><a href="q3textbrowser.html#Q3TextBrowser">Q3TextBrowser</a></b> ( QWidget * <i>parent</i> = 0, const char * <i>name</i> = 0 )</li>
 
45
<li><div class="fn"/>QString <b><a href="q3textbrowser.html#source-prop">source</a></b> () const</li>
 
46
</ul>
 
47
<ul>
 
48
<li><div class="fn"/>51 public functions inherited from <a href="q3textedit.html#public-functions">Q3TextEdit</a></li>
 
49
<li><div class="fn"/>46 public functions inherited from <a href="q3scrollview.html#public-functions">Q3ScrollView</a></li>
 
50
<li><div class="fn"/>4 public functions inherited from <a href="q3frame.html#public-functions">Q3Frame</a></li>
 
51
<li><div class="fn"/>13 public functions inherited from <a href="qframe.html#public-functions">QFrame</a></li>
 
52
<li><div class="fn"/>183 public functions inherited from <a href="qwidget.html#public-functions">QWidget</a></li>
 
53
<li><div class="fn"/>28 public functions inherited from <a href="qobject.html#public-functions">QObject</a></li>
 
54
<li><div class="fn"/>10 public functions inherited from <a href="qpaintdevice.html#public-functions">QPaintDevice</a></li>
 
55
</ul>
 
56
<a name="public-slots"></a>
 
57
<h3>Public Slots</h3>
 
58
<ul>
 
59
<li><div class="fn"/>virtual void <b><a href="q3textbrowser.html#backward">backward</a></b> ()</li>
 
60
<li><div class="fn"/>virtual void <b><a href="q3textbrowser.html#forward">forward</a></b> ()</li>
 
61
<li><div class="fn"/>virtual void <b><a href="q3textbrowser.html#home">home</a></b> ()</li>
 
62
<li><div class="fn"/>virtual void <b><a href="q3textbrowser.html#reload">reload</a></b> ()</li>
 
63
<li><div class="fn"/>virtual void <b><a href="q3textbrowser.html#source-prop">setSource</a></b> ( const QString &amp; <i>name</i> )</li>
 
64
<li><div class="fn"/>void <b><a href="q3textbrowser.html#setText-2">setText</a></b> ( const QString &amp; <i>txt</i> )</li>
 
65
</ul>
 
66
<ul>
 
67
<li><div class="fn"/>60 public slots inherited from <a href="q3textedit.html#public-slots">Q3TextEdit</a></li>
 
68
<li><div class="fn"/>8 public slots inherited from <a href="q3scrollview.html#public-slots">Q3ScrollView</a></li>
 
69
<li><div class="fn"/>17 public slots inherited from <a href="qwidget.html#public-slots">QWidget</a></li>
 
70
<li><div class="fn"/>1 public slot inherited from <a href="qobject.html#public-slots">QObject</a></li>
 
71
</ul>
 
72
<a name="signals"></a>
 
73
<h3>Signals</h3>
 
74
<ul>
 
75
<li><div class="fn"/>void <b><a href="q3textbrowser.html#anchorClicked">anchorClicked</a></b> ( const QString &amp; <i>name</i>, const QString &amp; <i>link</i> )</li>
 
76
<li><div class="fn"/>void <b><a href="q3textbrowser.html#backwardAvailable">backwardAvailable</a></b> ( bool <i>available</i> )</li>
 
77
<li><div class="fn"/>void <b><a href="q3textbrowser.html#forwardAvailable">forwardAvailable</a></b> ( bool <i>available</i> )</li>
 
78
<li><div class="fn"/>void <b><a href="q3textbrowser.html#highlighted">highlighted</a></b> ( const QString &amp; <i>link</i> )</li>
 
79
<li><div class="fn"/>void <b><a href="q3textbrowser.html#linkClicked">linkClicked</a></b> ( const QString &amp; <i>link</i> )</li>
 
80
<li><div class="fn"/>void <b><a href="q3textbrowser.html#sourceChanged">sourceChanged</a></b> ( const QString &amp; <i>src</i> )</li>
 
81
</ul>
 
82
<ul>
 
83
<li><div class="fn"/>14 signals inherited from <a href="q3textedit.html#signals">Q3TextEdit</a></li>
 
84
<li><div class="fn"/>5 signals inherited from <a href="q3scrollview.html#signals">Q3ScrollView</a></li>
 
85
<li><div class="fn"/>1 signal inherited from <a href="qwidget.html#signals">QWidget</a></li>
 
86
<li><div class="fn"/>1 signal inherited from <a href="qobject.html#signals">QObject</a></li>
 
87
</ul>
 
88
<a name="protected-functions"></a>
 
89
<h3>Protected Functions</h3>
 
90
<ul>
 
91
<li><div class="fn"/>virtual void <b><a href="q3textbrowser.html#keyPressEvent">keyPressEvent</a></b> ( QKeyEvent * <i>e</i> )</li>
 
92
</ul>
 
93
<ul>
 
94
<li><div class="fn"/>6 protected functions inherited from <a href="q3textedit.html#protected-functions">Q3TextEdit</a></li>
 
95
<li><div class="fn"/>17 protected functions inherited from <a href="q3scrollview.html#protected-functions">Q3ScrollView</a></li>
 
96
<li><div class="fn"/>5 protected functions inherited from <a href="q3frame.html#protected-functions">Q3Frame</a></li>
 
97
<li><div class="fn"/>39 protected functions inherited from <a href="qwidget.html#protected-functions">QWidget</a></li>
 
98
<li><div class="fn"/>7 protected functions inherited from <a href="qobject.html#protected-functions">QObject</a></li>
 
99
</ul>
 
100
<h3>Additional Inherited Members</h3>
 
101
<ul>
 
102
<li><div class="fn"/>2 static public members inherited from <a href="qframe.html#static-public-members">QFrame</a></li>
 
103
<li><div class="fn"/>4 static public members inherited from <a href="qwidget.html#static-public-members">QWidget</a></li>
 
104
<li><div class="fn"/>4 static public members inherited from <a href="qobject.html#static-public-members">QObject</a></li>
 
105
</ul>
 
106
<a name="details"></a>
 
107
<hr />
 
108
<h2>Detailed Description</h2>
 
109
<p>The Q3TextBrowser class provides a rich text browser with hypertext navigation.</p>
 
110
<p>This class extends <a href="q3textedit.html">Q3TextEdit</a> (in read-only mode), adding some navigation functionality so that users can follow links in hypertext documents. The contents of <a href="q3textedit.html">Q3TextEdit</a> is set with <a href="q3textbrowser.html#setText">setText</a>(), but Q3TextBrowser has an additional function, <a href="q3textbrowser.html#source-prop">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, &quot;<tt>#anchor&quot;</tt>), the text browser automatically scrolls to that position (using <a href="q3textedit.html#scrollToAnchor">scrollToAnchor</a>()). When the user clicks on a hyperlink, the browser will call <a href="q3textbrowser.html#source-prop">setSource</a>() itself, with the link's <tt>href</tt> value as argument. You can track the current source by connetion to the <a href="q3textbrowser.html#sourceChanged">sourceChanged</a>() signal.</p>
 
111
<p>Q3TextBrowser provides <a href="q3textbrowser.html#backward">backward</a>() and <a href="q3textbrowser.html#forward">forward</a>() slots which you can use to implement Back and Forward buttons. The <a href="q3textbrowser.html#home">home</a>() slot sets the text to the very first document displayed. The <a href="q3textbrowser.html#linkClicked">linkClicked</a>() signal is emitted when the user clicks a link.</p>
 
112
<p>By using <a href="q3textedit.html#setMimeSourceFactory">Q3TextEdit::setMimeSourceFactory</a>() you can provide your own subclass of <a href="q3mimesourcefactory.html">Q3MimeSourceFactory</a>. This makes it possible to access data from anywhere, for example from a network or from a database. See <a href="q3mimesourcefactory.html#data">Q3MimeSourceFactory::data</a>() for details.</p>
 
113
<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:</p>
 
114
<pre>&nbsp;   mimeSourceFactory()-&gt;setExtensionType(&quot;qml&quot;, &quot;text/utf8&quot;);</pre>
 
115
<p>This is to ensure that the factory is able to resolve the document names.</p>
 
116
<p>Q3TextBrowser interprets the tags it processes in accordance with the default style sheet. Change the style sheet with <a href="q3textedit.html#setStyleSheet">setStyleSheet</a>(); see <a href="porting4.html#qstylesheet">QStyleSheet</a> for details.</p>
 
117
<p>If you want to provide your users with editable rich text use <a href="q3textedit.html">Q3TextEdit</a>. If you want a text browser without hypertext navigation use <a href="q3textedit.html">Q3TextEdit</a>, and use <a href="q3textedit.html#readOnly-prop">Q3TextEdit::setReadOnly</a>() to disable editing. If you just need to display a small piece of rich text use <a href="porting4.html#qsimplerichtext">QSimpleRichText</a> or <a href="qlabel.html">QLabel</a>.</p>
 
118
<hr />
 
119
<h2>Property Documentation</h2>
 
120
<h3 class="fn"><a name="source-prop"></a>source : <a href="qstring.html">QString</a></h3>
 
121
<p>This property holds the name of the displayed document.</p>
 
122
<p>This is a an empty string if no document is displayed or if the source is unknown.</p>
 
123
<p>Setting this property uses the <a href="q3textedit.html#mimeSourceFactory">mimeSourceFactory</a>() to lookup the named document. It also checks for optional anchors and scrolls the document accordingly.</p>
 
124
<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="q3textbrowser.html#setText">setText</a>().</p>
 
125
<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="q3mimesourcefactory.html#data">Q3MimeSourceFactory::data</a>() for details.</p>
 
126
<p>Access functions:</p>
 
127
<ul>
 
128
<li><div class="fn"/><b>QString source () const</b></li>
 
129
<li><div class="fn"/><b>virtual void setSource ( const QString &amp; <i>name</i> )</b></li>
 
130
</ul>
 
131
<hr />
 
132
<h2>Member Function Documentation</h2>
 
133
<h3 class="fn"><a name="Q3TextBrowser"></a>Q3TextBrowser::Q3TextBrowser ( <a href="qwidget.html">QWidget</a> * <i>parent</i> = 0, const char * <i>name</i> = 0 )</h3>
 
134
<p>Constructs an empty <a href="q3textbrowser.html">Q3TextBrowser</a> called <i>name</i>, with parent <i>parent</i>.</p>
 
135
<h3 class="fn"><a name="anchorClicked"></a>void Q3TextBrowser::anchorClicked ( const <a href="qstring.html">QString</a> &amp; <i>name</i>, const <a href="qstring.html">QString</a> &amp; <i>link</i> )&nbsp;&nbsp;<tt> [signal]</tt></h3>
 
136
<p>This signal is emitted when the user clicks an anchor. The <i>link</i> is the value of the <tt>href</tt> i.e. the name of the target document. The <i>name</i> is the name of the anchor.</p>
 
137
<p>See also <a href="q3textbrowser.html#linkClicked">linkClicked</a>().</p>
 
138
<h3 class="fn"><a name="backward"></a>void Q3TextBrowser::backward ()&nbsp;&nbsp;<tt> [virtual slot]</tt></h3>
 
139
<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>
 
140
<p>See also <a href="q3textbrowser.html#forward">forward</a>() and <a href="q3textbrowser.html#backwardAvailable">backwardAvailable</a>().</p>
 
141
<h3 class="fn"><a name="backwardAvailable"></a>void Q3TextBrowser::backwardAvailable ( bool <i>available</i> )&nbsp;&nbsp;<tt> [signal]</tt></h3>
 
142
<p>This signal is emitted when the availability of <a href="q3textbrowser.html#backward">backward</a>() changes. <i>available</i> is false when the user is at <a href="q3textbrowser.html#home">home</a>(); otherwise it is true.</p>
 
143
<h3 class="fn"><a name="forward"></a>void Q3TextBrowser::forward ()&nbsp;&nbsp;<tt> [virtual slot]</tt></h3>
 
144
<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>
 
145
<p>See also <a href="q3textbrowser.html#backward">backward</a>() and <a href="q3textbrowser.html#forwardAvailable">forwardAvailable</a>().</p>
 
146
<h3 class="fn"><a name="forwardAvailable"></a>void Q3TextBrowser::forwardAvailable ( bool <i>available</i> )&nbsp;&nbsp;<tt> [signal]</tt></h3>
 
147
<p>This signal is emitted when the availability of <a href="q3textbrowser.html#forward">forward</a>() changes. <i>available</i> is true after the user navigates <a href="q3textbrowser.html#backward">backward</a>() and false when the user navigates or goes <a href="q3textbrowser.html#forward">forward</a>().</p>
 
148
<h3 class="fn"><a name="highlighted"></a>void Q3TextBrowser::highlighted ( const <a href="qstring.html">QString</a> &amp; <i>link</i> )&nbsp;&nbsp;<tt> [signal]</tt></h3>
 
149
<p>This signal is emitted when the user has selected but not activated a link in the document. <i>link</i> is the value of the <tt>href</tt> i.e. the name of the target document.</p>
 
150
<h3 class="fn"><a name="home"></a>void Q3TextBrowser::home ()&nbsp;&nbsp;<tt> [virtual slot]</tt></h3>
 
151
<p>Changes the document displayed to be the first document the browser displayed.</p>
 
152
<h3 class="fn"><a name="keyPressEvent"></a>void Q3TextBrowser::keyPressEvent ( <a href="qkeyevent.html">QKeyEvent</a> * <i>e</i> )&nbsp;&nbsp;<tt> [virtual protected]</tt></h3>
 
153
<p>The event <i>e</i> is used to provide the following keyboard shortcuts:</p>
 
154
<table align="center" cellpadding="2" cellspacing="1" border="0">
 
155
<tr valign="top" bgcolor="#a2c511"><th>Keypress</th><th>Action</th></tr>
 
156
<tr valign="top" bgcolor="#f0f0f0"><td>Alt+Left Arrow</td><td><a href="q3textbrowser.html#backward">backward</a>()</td></tr>
 
157
<tr valign="top" bgcolor="#e0e0e0"><td>Alt+Right Arrow</td><td><a href="q3textbrowser.html#forward">forward</a>()</td></tr>
 
158
<tr valign="top" bgcolor="#f0f0f0"><td>Alt+Up Arrow</td><td><a href="q3textbrowser.html#home">home</a>()</td></tr>
 
159
</table>
 
160
<p>Reimplemented from <a href="qwidget.html#keyPressEvent">QWidget</a>.</p>
 
161
<h3 class="fn"><a name="linkClicked"></a>void Q3TextBrowser::linkClicked ( const <a href="qstring.html">QString</a> &amp; <i>link</i> )&nbsp;&nbsp;<tt> [signal]</tt></h3>
 
162
<p>This signal is emitted when the user clicks a link. The <i>link</i> is the value of the <tt>href</tt> i.e. the name of the target document.</p>
 
163
<p>The <i>link</i> 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>
 
164
<p>See also <a href="q3textbrowser.html#anchorClicked">anchorClicked</a>().</p>
 
165
<h3 class="fn"><a name="reload"></a>void Q3TextBrowser::reload ()&nbsp;&nbsp;<tt> [virtual slot]</tt></h3>
 
166
<p>Reloads the current set source.</p>
 
167
<h3 class="fn"><a name="setText-2"></a>void Q3TextBrowser::setText ( const <a href="qstring.html">QString</a> &amp; <i>txt</i> )&nbsp;&nbsp;<tt> [slot]</tt></h3>
 
168
<p>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.</p>
 
169
<p>Sets the text to <i>txt</i>.</p>
 
170
<h3 class="fn"><a name="sourceChanged"></a>void Q3TextBrowser::sourceChanged ( const <a href="qstring.html">QString</a> &amp; <i>src</i> )&nbsp;&nbsp;<tt> [signal]</tt></h3>
 
171
<p>This signal is emitted when the mime source has changed, <i>src</i> being the new source.</p>
 
172
<p>Source changes happen both programmatically when calling <a href="q3textbrowser.html#source-prop">setSource</a>(), <a href="q3textbrowser.html#forward">forward</a>(), backword() or <a href="q3textbrowser.html#home">home</a>() or when the user clicks on links or presses the equivalent key sequences.</p>
 
173
<p /><address><hr /><div align="center">
 
174
<table width="100%" cellspacing="0" border="0"><tr class="address">
 
175
<td width="30%">Copyright &copy; 2005 <a href="trolltech.html">Trolltech</a></td>
 
176
<td width="40%" align="center"><a href="trademarks.html">Trademarks</a></td>
 
177
<td width="30%" align="right"><div align="right">Qt 4.0.0</div></td>
 
178
</tr></table></div></address></body>
 
179
</html>