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 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Qt Toolkit - QTextView Class</title><style type="text/css"><!--
h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm; }
a:link { color: #004faf; text-decoration: none }
a:visited { color: #672967; text-decoration: none }body { background: white; color: black; }
--></style>
</head><body bgcolor="#ffffff">
<table width="100%">
<tr><td><a href="index.html">
<img width="100" height="100" src="qtlogo.png"
alt="Home" border="0"><img width="100"
height="100" src="face.png" alt="Home" border="0">
</a><td valign=top><div align=right><img src="dochead.png" width="472" height="27"><br>
<a href="classes.html"><b>Classes</b></a>
-<a href="annotated.html">Annotated</a>
- <a href="hierarchy.html">Tree</a>
-<a href="functions.html">Functions</a>
-<a href="index.html">Home</a>
-<a href="topicals.html"><b>Structure</b></a>
</div>
</table>
<h1 align=center>QTextView Class Reference</h1><br clear="all">
<p>
A sophisticated single-page rich text viewer.
<a href="#details">More...</a>
<p>
<code>#include <<a href="qtextview-h.html">qtextview.h</a>></code>
<p>
Inherits <a href="qscrollview.html">QScrollView</a>.
<p>Inherited by <a href="qtextbrowser.html">QTextBrowser</a>.
<p><a href="qtextview-members.html">List of all member functions.</a>
<h2>Public Members</h2>
<ul>
<li><div class="fn"><a href="#0ff42a"><b>QTextView</b></a>(QWidget*parent=0, constchar*name=0)</div>
<li><div class="fn"><a href="#04169d"><b>QTextView</b></a>(constQString&text, constQString&context=QString::null, QWidget*parent=0, constchar*name=0)</div>
<li><div class="fn"><a href="#e8d0fe"><b>~QTextView</b></a>()</div>
<li><div class="fn">virtualvoid<a href="#c27a5a"><b>setText</b></a>(constQString&text, constQString&context)</div>
<li><div class="fn">void<a href="#e725da"><b>setText</b></a>(constQString&text)</div>
<li><div class="fn">virtualQString<a href="#42526c"><b>text</b></a>()const</div>
<li><div class="fn">virtualQString<a href="#9c7238"><b>context</b></a>()const</div>
<li><div class="fn">TextFormat<a href="#54df89"><b>textFormat</b></a>()const</div>
<li><div class="fn">void<a href="#29382c"><b>setTextFormat</b></a>(TextFormat)</div>
<li><div class="fn">QStyleSheet*<a href="#9084be"><b>styleSheet</b></a>()const</div>
<li><div class="fn">void<a href="#90c397"><b>setStyleSheet</b></a>(QStyleSheet*styleSheet)</div>
<li><div class="fn">void<a href="#0160b1"><b>setPaper</b></a>(constQBrush&pap)</div>
<li><div class="fn">constQBrush&<a href="#227750"><b>paper</b></a>()</div>
<li><div class="fn">constQBrush&<a href="#1fbfc2"><b>paper</b></a>()const</div>
<li><div class="fn">void<a href="#41c911"><b>setPaperColorGroup</b></a>(constQColorGroup&colgrp)</div>
<li><div class="fn">constQColorGroup&<a href="#2ae19a"><b>paperColorGroup</b></a>()const</div>
<li><div class="fn">void<a href="#152454"><b>setLinkColor</b></a>(constQColor&)</div>
<li><div class="fn">constQColor&<a href="#6580cf"><b>linkColor</b></a>()const</div>
<li><div class="fn">void<a href="#e3b75c"><b>setLinkUnderline</b></a>(bool)</div>
<li><div class="fn">bool<a href="#669450"><b>linkUnderline</b></a>()const</div>
<li><div class="fn">void<a href="#8d1f6b"><b>setMimeSourceFactory</b></a>(QMimeSourceFactory*factory)</div>
<li><div class="fn">QMimeSourceFactory*<a href="#3fa4aa"><b>mimeSourceFactory</b></a>()const</div>
<li><div class="fn">QString<a href="#ac4c3f"><b>documentTitle</b></a>()const</div>
<li><div class="fn">virtualint<a href="#7b0897"><b>heightForWidth</b></a>(intw)const</div>
<li><div class="fn">void<a href="#54a103"><b>append</b></a>(constQString&text)</div>
<li><div class="fn">bool<a href="#5d773f"><b>hasSelectedText</b></a>()const</div>
<li><div class="fn">QString<a href="#40c776"><b>selectedText</b></a>()const</div>
</ul>
<h2>Public Slots</h2>
<ul>
<li><div class="fn">void<a href="#5020bd"><b>copy</b></a>()</div>
<li><div class="fn">void<a href="#981343"><b>selectAll</b></a>()</div>
</ul>
<h2>Protected Members</h2>
<ul>
<li><div class="fn">virtualvoid<a href="#bb07eb"><b>keyPressEvent</b></a>(QKeyEvent*)</div>
<li><div class="fn">QRichText&<a href="#8a4a8f"><b>richText</b></a>()const</div>
</ul>
<h2>Properties</h2>
<table border=1 cellpadding=3 cellspacing=0>
<tr><th>Type<th>Name<th>READ<th>WRITE<th>Options
<tr><td>QString<td>text<td>text<td>setText<td>
<tr><td>TextFormat<td>textFormat<td>textFormat<td>setTextFormat<td>
<tr><td>QBrush<td>paper<td>paper<td>setPaper<td>
<tr><td>QColorGroup<td>paperColorGroup<td>paperColorGroup<td>setPaperColorGroup<td>
<tr><td>QColor<td>linkColor<td>linkColor<td>setLinkColor<td>
<tr><td>bool<td>linkUnderline<td>linkUnderline<td>setLinkUnderline<td>
<tr><td>QString<td>documentTitle<td>documentTitle<td> <td>
</table>
<hr><h2><a name="details"></a>Detailed Description</h2>
A sophisticated single-page rich text viewer.
<p>
Unlike <a href="qsimplerichtext.html">QSimpleRichText</a>, which merely draws small pieces of rich
text, a QTextView is a real widget, with scrollbars when necessary,
for showing large text documents.
<p>The rendering style and available tags are defined by a
<a href="#9084be">styleSheet</a>(). Currently, a small XML/CSS1 subset including embedded
images and tables is supported. See <a href="qstylesheet.html">QStyleSheet</a> for
details. Possible images within the text document are resolved by
using a <a href="qmimesourcefactory.html">QMimeSourceFactory</a>. See <a href="#8d1f6b">setMimeSourceFactory</a>() for details.
<p>Using QTextView is quite similar to <a href="qlabel.html">QLabel</a>. It's mainly a call to
<a href="#c27a5a">setText</a>() to set the contents. Setting the background color is
slightly different from other widgets, since a text view is a
scrollable widget that naturally provides a scrolling background. You
can specify the colorgroup of the displayed text with
<a href="#41c911">setPaperColorGroup</a>() or directly define the paper background with
<a href="#0160b1">setPaper</a>(). QTextView supports both plain color and complex pixmap
backgrounds.
<p>Note that we do not intend to add a full-featured web browser widget
to Qt (since that would easily double Qt's size and only few
applications would benefit from it). In particular, the rich text
support in Qt is supposed to provide a fast, portable and sufficient
way to add reasonable online help facilities to applications. We
will, however, extend it to some degree in future versions of Qt.
<p>For even more, like hypertext capabilities, see <a href="qtextbrowser.html">QTextBrowser</a>.
<hr><h2>Member Function Documentation</h2>
<h3 class="fn"><a name="0ff42a"></a>QTextView::QTextView(<a href="qwidget.html">QWidget</a>*parent=0, constchar*name=0)</h3>
<p>Constructs an empty QTextView
with the standard <em>parent</em> and <em>name</em> optional arguments.
<h3 class="fn"><a name="04169d"></a>QTextView::QTextView(const<a href="qstring.html">QString</a>&text, const<a href="qstring.html">QString</a>&context=QString::null, <a href="qwidget.html">QWidget</a>*parent=0, constchar*name=0)</h3>
<p>Constructs a QTextView displaying the contents <em>text</em> with context
<em>context,</em> with the standard <em>parent</em> and <em>name</em> optional
arguments.
<h3 class="fn"><a name="e8d0fe"></a>QTextView::~QTextView()</h3>
<p>Destructs the view.
<h3 class="fn">void<a name="54a103"></a>QTextView::append(const<a href="qstring.html">QString</a>&text)</h3>
<p>Appends <em>text</em> to the current text.
<p>Useful for log viewers.<p><b>Warning:</b> This function has known problems (incorrect painting and
layouting). If this problem occures to you, use <a href="#c27a5a">setText</a>( <a href="#42526c">text</a>() +
theNewText ) instead. The new richtext engine, which is part of Qt
3.0, is able to handle append(), insert(), etc. properly.
<h3 class="fn"><a href="qstring.html">QString</a><a name="9c7238"></a>QTextView::context()const <code>[virtual]</code></h3>
<p>Returns the context of the view.
<p>See also <a href="#42526c">text</a>() and <a href="#c27a5a">setText</a>().
<h3 class="fn">void<a name="5020bd"></a>QTextView::copy() <code>[slot]</code></h3>
<p>Copies the marked text to the clipboard.
<h3 class="fn"><a href="qstring.html">QString</a><a name="ac4c3f"></a>QTextView::documentTitle()const</h3>
<p>Returns the document title parsed from the content.
<h3 class="fn">void<a name="7fd2a8"></a>QTextView::drawContentsOffset(<a href="qpainter.html">QPainter</a>*p, intox, intoy, intcx, intcy, intcw, intch) <code>[virtualprotected]</code></h3>
<p>Reimplemented for internal reasons; the API is not affected.
<p>Reimplemented from <a href="qscrollview.html#d9fbf6">QScrollView.</a>
<h3 class="fn">void<a name="7dd99d"></a>QTextView::focusInEvent(<a href="qfocusevent.html">QFocusEvent</a>*) <code>[virtualprotected]</code></h3>
<p>Reimplemented for internal reasons; the API is not affected.
<p>Reimplemented from <a href="qwidget.html#21a4b8">QWidget.</a>
<h3 class="fn">void<a name="54892c"></a>QTextView::focusOutEvent(<a href="qfocusevent.html">QFocusEvent</a>*) <code>[virtualprotected]</code></h3>
<p>Reimplemented for internal reasons; the API is not affected.
<p>Reimplemented from <a href="qwidget.html#de664a">QWidget.</a>
<h3 class="fn">bool<a name="5d773f"></a>QTextView::hasSelectedText()const</h3>
<p>Returns TRUE if there is any text selected, FALSE otherwise.
<p>See also <a href="#40c776">selectedText</a>().
<h3 class="fn">int<a name="7b0897"></a>QTextView::heightForWidth(intw)const <code>[virtual]</code></h3>
<p>Returns the height of the view given a width of <em>w.</em>
<p>Reimplemented from <a href="qwidget.html#1a2d58">QWidget.</a>
<h3 class="fn">void<a name="bb07eb"></a>QTextView::keyPressEvent(<a href="qkeyevent.html">QKeyEvent</a>*e) <code>[virtualprotected]</code></h3>
<p>Provides scrolling and paging.
<p>Reimplemented from <a href="qwidget.html#0a4482">QWidget.</a>
<h3 class="fn">const<a href="qcolor.html">QColor</a>&<a name="6580cf"></a>QTextView::linkColor()const</h3>
<p>Returns the current link color.
<p>The color may either have been set with <a href="#152454">setLinkColor</a>() or stem from
the document's body tag.
<p>See also <a href="#152454">setLinkColor</a>().
<h3 class="fn">bool<a name="669450"></a>QTextView::linkUnderline()const</h3>
<p>Returns whether or not links should be displayed underlined.
<h3 class="fn"><a href="qmimesourcefactory.html">QMimeSourceFactory</a>*<a name="3fa4aa"></a>QTextView::mimeSourceFactory()const</h3>
<p>Returns the current mime source factory for the view.
<p>See also <a href="#8d1f6b">setMimeSourceFactory</a>().
<h3 class="fn">void<a name="3ed6c0"></a>QTextView::paletteChange(const<a href="qpalette.html">QPalette</a>&p) <code>[virtualprotected]</code></h3>
<p>Reimplemented for internal reasons; the API is not affected.
<p>Reimplemented from <a href="qwidget.html#5825b1">QWidget.</a>
<h3 class="fn">const<a href="qbrush.html">QBrush</a>&<a name="227750"></a>QTextView::paper()</h3>
<p>Returns the brush used to paint the background.
<h3 class="fn">const<a href="qbrush.html">QBrush</a>&<a name="1fbfc2"></a>QTextView::paper()const</h3>
<p>Returns the brush used to paint the background.
<h3 class="fn">const<a href="qcolorgroup.html">QColorGroup</a>&<a name="2ae19a"></a>QTextView::paperColorGroup()const</h3>
<p>Returns the colorgroup of the paper.
<p>See also <a href="#41c911">setPaperColorGroup</a>() and <a href="#0160b1">setPaper</a>().
<h3 class="fn">void<a name="586ea1"></a>QTextView::resizeEvent(<a href="qresizeevent.html">QResizeEvent</a>*e) <code>[virtualprotected]</code></h3>
<p>Reimplemented for internal reasons; the API is not affected.
<p>Reimplemented from <a href="qwidget.html#7d375f">QWidget.</a>
<h3 class="fn">QRichText&<a name="8a4a8f"></a>QTextView::richText()const <code>[protected]</code></h3>
<p>Returns the document defining the view as drawable and queryable rich
text object. This is not currently useful for applications.
<h3 class="fn">void<a name="981343"></a>QTextView::selectAll() <code>[slot]</code></h3>
<p>Selects all text.
<h3 class="fn"><a href="qstring.html">QString</a><a name="40c776"></a>QTextView::selectedText()const</h3>
<p>Returns a copy of the selected text in plain text format.
<p>See also <a href="#5d773f">hasSelectedText</a>().
<h3 class="fn">void<a name="152454"></a>QTextView::setLinkColor(const<a href="qcolor.html">QColor</a>&col)</h3>
<p>Sets the color used to display links in the document to <code>col.</code>
<p>See also <a href="#6580cf">linkColor</a>().
<h3 class="fn">void<a name="e3b75c"></a>QTextView::setLinkUnderline(boolu)</h3>
<p>Defines whether or not links should be displayed underlined.
<h3 class="fn">void<a name="8d1f6b"></a>QTextView::setMimeSourceFactory(<a href="qmimesourcefactory.html">QMimeSourceFactory</a>*factory)</h3>
<p>Sets the mime source factory for the view. The factory is used to
resolve named references within rich text documents. If no factory
has been specified, the text view uses the default factory
<a href="qmimesourcefactory.html#5c7072">QMimeSourceFactory::defaultFactory</a>().
<p>Ownership of <em>factory</em> is <em>not</em> transferred to make it possible
for several text view widgets to share the same mime source.
<p>See also <a href="#3fa4aa">mimeSourceFactory</a>().
<h3 class="fn">void<a name="0160b1"></a>QTextView::setPaper(const<a href="qbrush.html">QBrush</a>&pap)</h3>
<p>Sets the brush to use as the background to <em>pap.</em>
<p>This may be a nice parchment or marble pixmap or simply another
plain color.
<p>Technically, setPaper() is just a convenience function to set the
base brush of the <a href="#2ae19a">paperColorGroup</a>().
<p>See also <a href="#1fbfc2">paper</a>().
<h3 class="fn">void<a name="41c911"></a>QTextView::setPaperColorGroup(const<a href="qcolorgroup.html">QColorGroup</a>&colgrp)</h3>
<p>Sets the full colorgroup of the paper to <em>colgrp.</em> If not specified
otherwise in the document itself, any text will use
<a href="qcolorgroup.html#ddea87">QColorGroup::text</a>(). The background will be painted with
<a href="qcolorgroup.html#dc90ba">QColorGroup::brush</a>(QColorGroup::Base).
<p>See also <a href="#2ae19a">paperColorGroup</a>() and <a href="#0160b1">setPaper</a>().
<h3 class="fn">void<a name="90c397"></a>QTextView::setStyleSheet(<a href="qstylesheet.html">QStyleSheet</a>*styleSheet)</h3>
<p>Sets the style sheet of the view.
<p>See also <a href="#9084be">styleSheet</a>().
<h3 class="fn">void<a name="c27a5a"></a>QTextView::setText(const<a href="qstring.html">QString</a>&text, const<a href="qstring.html">QString</a>&context) <code>[virtual]</code></h3>
<p>Changes the contents of the view to the string <em>text</em> and the
context to <em>context.</em>
<p><em>text</em> may be interpreted either as plain text or as rich text,
depending on the <a href="#54df89">textFormat</a>(). The default setting is <code>AutoText,</code>
i.e. the text view autodetects the format from <em>text.</em>
<p>The optional <em>context</em> is used to resolve references within the
text document, for example image sources. It is passed directly to
the <a href="#3fa4aa">mimeSourceFactory</a>() when quering data.
<p>See also <a href="#42526c">text</a>() and <a href="#29382c">setTextFormat</a>().
<p>Reimplemented in <a href="qtextbrowser.html#270211">QTextBrowser</a>.
<h3 class="fn">void<a name="e725da"></a>QTextView::setText(const<a href="qstring.html">QString</a>&text)</h3>
<p>This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
<p>Changes the contents of the view to the string <em>text.</em>
<p><em>text</em> may be interpreted either as plain text or as rich text,
depending on the <a href="#54df89">textFormat</a>(). The default setting is <code>AutoText,</code>
i.e. the text view autodetects the format from <em>text.</em>
<p>This function calls <a href="#c27a5a">setText</a>( text, QString::null ), i.e. it sets a
text without any context.
<p>See also <a href="#42526c">text</a>() and <a href="#29382c">setTextFormat</a>().
<h3 class="fn">void<a name="29382c"></a>QTextView::setTextFormat(<a href="qt.html#TextFormat">Qt::TextFormat</a>format)</h3>
<p>Sets the text format to <em>format.</em> Possible choices are
<ul>
<li> <code>PlainText</code> - all characters are displayed verbatim,
including all blanks and linebreaks.
<li> <code>RichText</code> - rich text rendering. The available
styles are defined in the default stylesheet
<a href="qstylesheet.html#50ded7">QStyleSheet::defaultSheet</a>().
<li> <code>AutoText</code> - this is also the default. The label
autodetects which rendering style suits best, <code>PlainText</code>
or <code>RichText.</code> Technically, this is done by using the
<a href="qstylesheet.html#58b86f">QStyleSheet::mightBeRichText</a>() heuristic.
</ul>
<h3 class="fn">void<a name="6e56d6"></a>QTextView::showEvent(<a href="qshowevent.html">QShowEvent</a>*) <code>[virtualprotected]</code></h3>
<p>Reimplemented for internal reasons; the API is not affected.
<p>Reimplemented from <a href="qwidget.html#542dc0">QWidget.</a>
<h3 class="fn"><a href="qstylesheet.html">QStyleSheet</a>*<a name="9084be"></a>QTextView::styleSheet()const</h3>
<p>Returns the current style sheet of the view.
<p>See also <a href="#90c397">setStyleSheet</a>().
<h3 class="fn"><a href="qstring.html">QString</a><a name="42526c"></a>QTextView::text()const <code>[virtual]</code></h3>
<p>Returns the contents of the view.
<p>See also <a href="#9c7238">context</a>() and <a href="#c27a5a">setText</a>().
<h3 class="fn">Qt::TextFormat<a name="54df89"></a>QTextView::textFormat()const</h3>
<p>Returns the current text format.
<p>See also <a href="#29382c">setTextFormat</a>().
<h3 class="fn">void<a name="d01e49"></a>QTextView::viewportMouseMoveEvent(<a href="qmouseevent.html">QMouseEvent</a>*e) <code>[virtualprotected]</code></h3>
<p>Reimplemented for internal reasons; the API is not affected.
<p>Reimplemented from <a href="qscrollview.html#d850f6">QScrollView.</a>
<h3 class="fn">void<a name="4cc80d"></a>QTextView::viewportMousePressEvent(<a href="qmouseevent.html">QMouseEvent</a>*e) <code>[virtualprotected]</code></h3>
<p>Reimplemented for internal reasons; the API is not affected.
<p>Reimplemented from <a href="qscrollview.html#013843">QScrollView.</a>
<h3 class="fn">void<a name="989864"></a>QTextView::viewportMouseReleaseEvent(<a href="qmouseevent.html">QMouseEvent</a>*e) <code>[virtualprotected]</code></h3>
<p>Reimplemented for internal reasons; the API is not affected.
<p>Reimplemented from <a href="qscrollview.html#ff7b46">QScrollView.</a>
<h3 class="fn">void<a name="3602fa"></a>QTextView::viewportResizeEvent(<a href="qresizeevent.html">QResizeEvent</a>*) <code>[virtualprotected]</code></h3>
<p>Reimplemented for internal reasons; the API is not affected.
<p>Reimplemented from <a href="qscrollview.html#77c5ed">QScrollView.</a>
<hr><p>
Search the documentation, FAQ, qt-interest archive and more (uses
<a href="http://www.trolltech.com">www.trolltech.com</a>):<br>
<form method=post action="http://www.trolltech.com/search.cgi">
<input type=hidden name="version" value="2.3.2"><nobr>
<input size="50" name="search"><input type=submit value="Search">
</nobr></form><hr><p>
This file is part of the <a href="index.html">Qt toolkit</a>,
copyright © 1995-2001
<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 2001 Trolltech<td><a href="http://www.trolltech.com/trademarks.html">Trademarks</a>
<td align="right"><div align="right">Qt version 2.3.2</div>
</table></div></address></body></html>
|