summaryrefslogtreecommitdiffstats
path: root/doc/man/man3/tqtextbrowser.3qt
blob: 27298d63034cbf2563f593a56c349f1ff72e1b7c (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
'\" t
.TH QTextBrowser 3qt "2 February 2007" "Trolltech AS" \" -*- nroff -*-
.\" Copyright 1992-2007 Trolltech ASA.  All rights reserved.  See the
.\" license file included in the distribution for a complete license
.\" statement.
.\"
.ad l
.nh
.SH NAME
QTextBrowser \- Rich text browser with hypertext navigation
.SH SYNOPSIS
\fC#include <ntqtextbrowser.h>\fR
.PP
Inherits QTextEdit.
.PP
.SS "Public Members"
.in +1c
.ti -1c
.BI "\fBQTextBrowser\fR ( QWidget * parent = 0, const char * name = 0 )"
.br
.ti -1c
.BI "QString \fBsource\fR () const"
.br
.in -1c
.SS "Public Slots"
.in +1c
.ti -1c
.BI "virtual void \fBsetSource\fR ( const QString & name )"
.br
.ti -1c
.BI "virtual void \fBbackward\fR ()"
.br
.ti -1c
.BI "virtual void \fBforward\fR ()"
.br
.ti -1c
.BI "virtual void \fBhome\fR ()"
.br
.ti -1c
.BI "virtual void \fBreload\fR ()"
.br
.in -1c
.SS "Signals"
.in +1c
.ti -1c
.BI "void \fBbackwardAvailable\fR ( bool available )"
.br
.ti -1c
.BI "void \fBforwardAvailable\fR ( bool available )"
.br
.ti -1c
.BI "void \fBsourceChanged\fR ( const QString & src )"
.br
.ti -1c
.BI "void \fBhighlighted\fR ( const QString & link )"
.br
.ti -1c
.BI "void \fBlinkClicked\fR ( const QString & link )"
.br
.ti -1c
.BI "void \fBanchorClicked\fR ( const QString & name, const QString & link )"
.br
.in -1c
.SS "Properties"
.in +1c
.ti -1c
.BI "bool \fBmodified\fR - whether the contents have been modified  \fI(read " "only" ")\fR"
.br
.ti -1c
.BI "bool \fBoverwriteMode\fR - this text browser's overwrite mode  \fI(read " "only" ")\fR"
.br
.ti -1c
.BI "bool \fBreadOnly\fR - whether the contents are read only  \fI(read " "only" ")\fR"
.br
.ti -1c
.BI "QString \fBsource\fR - the name of the displayed document"
.br
.ti -1c
.BI "int \fBundoDepth\fR - this text browser's undo depth  \fI(read " "only" ")\fR"
.br
.ti -1c
.BI "bool \fBundoRedoEnabled\fR - whether undo and redo are enabled  \fI(read " "only" ")\fR"
.br
.in -1c
.SS "Protected Members"
.in +1c
.ti -1c
.BI "virtual void \fBkeyPressEvent\fR ( QKeyEvent * e )"
.br
.in -1c
.SH DESCRIPTION
The QTextBrowser class provides a rich text browser with hypertext navigation.
.PP
This class extends QTextEdit (in read-only mode), adding some navigation functionality so that users can follow links in hypertext documents. The contents of QTextEdit is set with setText(), but QTextBrowser has an additional function, setSource(), 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, "\fC#anchor"\fR), 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 \fChref\fR value as argument. You can track the current source by connetion to the sourceChanged() signal.
.PP
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 linkClicked() signal is emitted when the user clicks a link.
.PP
By using QTextEdit::setMimeSourceFactory() you can provide your own subclass of QMimeSourceFactory. This makes it possible to access data from anywhere, for example from a network or from a database. See QMimeSourceFactory::data() for details.
.PP
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:
.PP
.nf
.br
    mimeSourceFactory()->setExtensionType("qml", "text/utf8");
.br
.fi
This is to ensure that the factory is able to resolve the document names.
.PP
QTextBrowser interprets the tags it processes in accordance with the default style sheet. Change the style sheet with setStyleSheet(); see QStyleSheet for details.
.PP
If you want to provide your users with editable rich text 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 QSimpleRichText or QLabel.
.PP
.ce 1
.B "[Image Omitted]"
.PP

.ce 1
.B "[Image Omitted]"
.PP
See also Advanced Widgets, Help System, and Text Related Classes.
.SH MEMBER FUNCTION DOCUMENTATION
.SH "QTextBrowser::QTextBrowser ( QWidget * parent = 0, const char * name = 0 )"
Constructs an empty QTextBrowser called \fIname\fR, with parent \fIparent\fR.
.SH "void QTextBrowser::anchorClicked ( const QString & name, const QString & link )\fC [signal]\fR"
This signal is emitted when the user clicks an anchor. The \fIlink\fR is the value of the \fChref\fR i.e. the name of the target document. The \fIname\fR is the name of the anchor.
.PP
See also linkClicked().
.SH "void QTextBrowser::backward ()\fC [virtual slot]\fR"
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.
.PP
See also forward() and backwardAvailable().
.PP
Example: helpviewer/helpwindow.cpp.
.SH "void QTextBrowser::backwardAvailable ( bool available )\fC [signal]\fR"
This signal is emitted when the availability of backward() changes. \fIavailable\fR is FALSE when the user is at home(); otherwise it is TRUE.
.PP
Example: helpviewer/helpwindow.cpp.
.SH "void QTextBrowser::forward ()\fC [virtual slot]\fR"
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.
.PP
See also backward() and forwardAvailable().
.PP
Example: helpviewer/helpwindow.cpp.
.SH "void QTextBrowser::forwardAvailable ( bool available )\fC [signal]\fR"
This signal is emitted when the availability of forward() changes. \fIavailable\fR is TRUE after the user navigates backward() and FALSE when the user navigates or goes forward().
.PP
Example: helpviewer/helpwindow.cpp.
.SH "void QTextBrowser::highlighted ( const QString & link )\fC [signal]\fR"
This signal is emitted when the user has selected but not activated a link in the document. \fIlink\fR is the value of the \fChref\fR i.e. the name of the target document.
.PP
Example: helpviewer/helpwindow.cpp.
.SH "void QTextBrowser::home ()\fC [virtual slot]\fR"
Changes the document displayed to be the first document the browser displayed.
.PP
Example: helpviewer/helpwindow.cpp.
.SH "void QTextBrowser::keyPressEvent ( QKeyEvent * e )\fC [virtual protected]\fR"
The event \fIe\fR is used to provide the following keyboard shortcuts: <center>.nf
.TS
l - l. Keypress Action Alt+Left Arrow backward() Alt+Right Arrow forward() Alt+Up Arrow
.TE
.fi
</center>
.PP
Reimplemented from QTextEdit.
.SH "void QTextBrowser::linkClicked ( const QString & link )\fC [signal]\fR"
This signal is emitted when the user clicks a link. The \fIlink\fR is the value of the \fChref\fR i.e. the name of the target document.
.PP
The \fIlink\fR 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.
.PP
See also anchorClicked() and context().
.SH "void QTextBrowser::reload ()\fC [virtual slot]\fR"
Reloads the current set source.
.SH "void QTextBrowser::setSource ( const QString & name )\fC [virtual slot]\fR"
Sets the name of the displayed document to \fIname\fR. See the "source" property for details.
.SH "QString QTextBrowser::source () const"
Returns the name of the displayed document. See the "source" property for details.
.SH "void QTextBrowser::sourceChanged ( const QString & src )\fC [signal]\fR"
This signal is emitted when the mime source has changed, \fIsrc\fR being the new source.
.PP
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.
.PP
Example: helpviewer/helpwindow.cpp.
.SS "Property Documentation"
.SH "bool modified"
This property holds whether the contents have been modified.
.SH "bool overwriteMode"
This property holds this text browser's overwrite mode.
.SH "bool readOnly"
This property holds whether the contents are read only.
.SH "QString source"
This property holds the name of the displayed document.
.PP
This is a QString::null if no document is displayed or if the source is unknown.
.PP
Setting this property uses the mimeSourceFactory() to lookup the named document. It also checks for optional anchors and scrolls the document accordingly.
.PP
If the first tag in the document is \fC<qt type=detail>\fR, 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 setText().
.PP
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 \fC*.html\fR and \fC*.txt\fR with reasonable defaults. See QMimeSourceFactory::data() for details.
.PP
Set this property's value with setSource() and get this property's value with source().
.SH "int undoDepth"
This property holds this text browser's undo depth.
.SH "bool undoRedoEnabled"
This property holds whether undo and redo are enabled.
.PP

.SH "SEE ALSO"
.BR http://doc.trolltech.com/ntqtextbrowser.html
.BR http://www.trolltech.com/faq/tech.html
.SH COPYRIGHT
Copyright 1992-2007 Trolltech ASA, http://www.trolltech.com.  See the
license file included in the distribution for a complete license
statement.
.SH AUTHOR
Generated automatically from the source code.
.SH BUGS
If you find a bug in Qt, please report it as described in
.BR http://doc.trolltech.com/bughowto.html .
Good bug reports help us to help you. Thank you.
.P
The definitive TQt documentation is provided in HTML format; it is
located at $TQTDIR/doc/html and can be read using TQt Assistant or with
a web browser. This man page is provided as a convenience for those
users who prefer man pages, although this format is not officially
supported by Trolltech. 
.P
If you find errors in this manual page, please report them to
.BR qt-bugs@trolltech.com .
Please include the name of the manual page (tqtextbrowser.3qt) and the Qt
version (3.3.8).