You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
tqt3/doc/html/tqtextbrowser.html

266 lines
15 KiB

<!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/tqtextbrowser.cpp:59 -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>TQTextBrowser 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>TQTextBrowser Class Reference</h1>
<p>The TQTextBrowser class provides a rich text browser with hypertext navigation.
<a href="#details">More...</a>
<p><tt>#include &lt;<a href="tqtextbrowser-h.html">tqtextbrowser.h</a>&gt;</tt>
<p>Inherits <a href="tqtextedit.html">TQTextEdit</a>.
<p><a href="tqtextbrowser-members.html">List of all member functions.</a>
<h2>Public Members</h2>
<ul>
<li class=fn><a href="#TQTextBrowser"><b>TQTextBrowser</b></a> ( TQWidget&nbsp;*&nbsp;parent = 0, const&nbsp;char&nbsp;*&nbsp;name = 0 )</li>
<li class=fn>TQString <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;TQString&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;TQString&nbsp;&amp;&nbsp;src )</li>
<li class=fn>void <a href="#highlighted"><b>highlighted</b></a> ( const&nbsp;TQString&nbsp;&amp;&nbsp;link )</li>
<li class=fn>void <a href="#linkClicked"><b>linkClicked</b></a> ( const&nbsp;TQString&nbsp;&amp;&nbsp;link )</li>
<li class=fn>void <a href="#anchorClicked"><b>anchorClicked</b></a> ( const&nbsp;TQString&nbsp;&amp;&nbsp;name, const&nbsp;TQString&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>TQString <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> ( TQKeyEvent&nbsp;*&nbsp;e )</li>
</ul>
<hr><a name="details"></a><h2>Detailed Description</h2>
The TQTextBrowser class provides a rich text browser with hypertext navigation.
<p>
<p> This class extends <a href="tqtextedit.html">TQTextEdit</a> (in read-only mode), adding some
navigation functionality so that users can follow links in
hypertext documents. The contents of TQTextEdit is set with
<a href="tqtextedit.html#setText">setText</a>(), but TQTextBrowser 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="tqtextedit.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> TQTextBrowser 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="tqtextedit.html#setMimeSourceFactory">TQTextEdit::setMimeSourceFactory</a>() you can provide your
own subclass of <a href="qmimesourcefactory.html">TQMimeSourceFactory</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">TQMimeSourceFactory::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="tqtextedit.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> TQTextBrowser interprets the tags it processes in accordance with
the default style sheet. Change the style sheet with
<a href="tqtextedit.html#setStyleSheet">setStyleSheet</a>(); see <a href="ntqstylesheet.html">TQStyleSheet</a> for details.
<p> If you want to provide your users with editable rich text use
<a href="tqtextedit.html">TQTextEdit</a>. If you want a text browser without hypertext navigation
use TQTextEdit, and use <a href="tqtextedit.html#setReadOnly">TQTextEdit::setReadOnly</a>() to disable
editing. If you just need to display a small piece of rich text
use <a href="ntqsimplerichtext.html">TQSimpleRichText</a> or <a href="ntqlabel.html">TQLabel</a>.
<p> <img src=tqtextbrowser-m.png> <img src=tqtextbrowser-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="TQTextBrowser"></a>TQTextBrowser::TQTextBrowser ( <a href="tqwidget.html">TQWidget</a>&nbsp;*&nbsp;parent = 0, const&nbsp;char&nbsp;*&nbsp;name = 0 )
</h3>
Constructs an empty TQTextBrowser called <em>name</em>, with parent <em>parent</em>.
<h3 class=fn>void <a name="anchorClicked"></a>TQTextBrowser::anchorClicked ( const&nbsp;<a href="tqstring.html">TQString</a>&nbsp;&amp;&nbsp;name, const&nbsp;<a href="tqstring.html">TQString</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>TQTextBrowser::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>TQTextBrowser::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>TQTextBrowser::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>TQTextBrowser::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>TQTextBrowser::highlighted ( const&nbsp;<a href="tqstring.html">TQString</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>TQTextBrowser::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>TQTextBrowser::keyPressEvent ( <a href="qkeyevent.html">TQKeyEvent</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="tqtextedit.html#keyPressEvent">TQTextEdit</a>.
<h3 class=fn>void <a name="linkClicked"></a>TQTextBrowser::linkClicked ( const&nbsp;<a href="tqstring.html">TQString</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="tqtextedit.html#context">context</a>().
<h3 class=fn>void <a name="reload"></a>TQTextBrowser::reload ()<tt> [virtual slot]</tt>
</h3>
Reloads the current set source.
<h3 class=fn>void <a name="setSource"></a>TQTextBrowser::setSource ( const&nbsp;<a href="tqstring.html">TQString</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="tqtextbrowser.html#source-prop">"source"</a> property for details.
<h3 class=fn><a href="tqstring.html">TQString</a> <a name="source"></a>TQTextBrowser::source () const
</h3><p>Returns the name of the displayed document.
See the <a href="tqtextbrowser.html#source-prop">"source"</a> property for details.
<h3 class=fn>void <a name="sourceChanged"></a>TQTextBrowser::sourceChanged ( const&nbsp;<a href="tqstring.html">TQString</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="tqstring.html">TQString</a> <a name="source-prop"></a>source</h3>
<p>This property holds the name of the displayed document.
<p>This is a <a href="tqstring.html#TQString-null">TQString::null</a> if no document is displayed or if the
source is unknown.
<p> Setting this property uses the <a href="tqtextedit.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="tqtextedit.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">TQMimeSourceFactory::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">TQt 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>TQt 3.3.8</div>
</table></div></address></body>
</html>