<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <!-- /tmp/qt-3.0-reggie-28534/qt-x11-free-3.0.2/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"><!-- 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: #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 Classes</font></a> | <a href="mainclasses.html"> <font color="#004faf">Main Classes</font></a> | <a href="annotated.html"> <font color="#004faf">Annotated</font></a> | <a href="groups.html"> <font color="#004faf">Grouped 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 <<a href="qtextbrowser-h.html">qtextbrowser.h</a>></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><div class=fn><a href="#QTextBrowser"><b>QTextBrowser</b></a> ( QWidget * parent = 0, const char * name = 0 )</div></li> <li><div class=fn>QString <a href="#source"><b>source</b></a> () const</div></li> </ul> <h2>Public Slots</h2> <ul> <li><div class=fn>virtual void <a href="#setSource"><b>setSource</b></a> ( const QString & name )</div></li> <li><div class=fn>virtual void <a href="#backward"><b>backward</b></a> ()</div></li> <li><div class=fn>virtual void <a href="#forward"><b>forward</b></a> ()</div></li> <li><div class=fn>virtual void <a href="#home"><b>home</b></a> ()</div></li> <li><div class=fn>virtual void <a href="#reload"><b>reload</b></a> ()</div></li> </ul> <h2>Signals</h2> <ul> <li><div class=fn>void <a href="#backwardAvailable"><b>backwardAvailable</b></a> ( bool available )</div></li> <li><div class=fn>void <a href="#forwardAvailable"><b>forwardAvailable</b></a> ( bool available )</div></li> <li><div class=fn>void <a href="#highlighted"><b>highlighted</b></a> ( const QString & href )</div></li> <li><div class=fn>void <a href="#linkClicked"><b>linkClicked</b></a> ( const QString & link )</div></li> </ul> <h2>Properties</h2> <ul> <li><div class=fn>QString <a href="#source-prop"><b>source</b></a> - the name of the currently displayed document</div></li> </ul> <h2>Protected Members</h2> <ul> <li><div class=fn>virtual void <a href="#keyPressEvent"><b>keyPressEvent</b></a> ( QKeyEvent * e )</div></li> </ul> <hr><a name="details"></a><h2>Detailed Description</h2> The QTextBrowser class provides a rich text browser with hypertext navigation. <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. <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>()->setExtensionType("qml", "text/utf8"); </pre> This is to ensure that the factory is able to resolve the document names. <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> * parent = 0, const char * name = 0 ) </h3> Constructs an empty QTextBrowser with parent <em>parent</em> called <em>name</em>. <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#x1427">helpviewer/helpwindow.cpp</a>. <h3 class=fn>void <a name="backwardAvailable"></a>QTextBrowser::backwardAvailable ( bool available )<tt> [signal]</tt> </h3> <p> This signal is emitted when the availability of the <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#x1428">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#x1429">helpviewer/helpwindow.cpp</a>. <h3 class=fn>void <a name="forwardAvailable"></a>QTextBrowser::forwardAvailable ( bool available )<tt> [signal]</tt> </h3> <p> This signal is emitted when the availability of the <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#x1430">helpviewer/helpwindow.cpp</a>. <h3 class=fn>void <a name="highlighted"></a>QTextBrowser::highlighted ( const <a href="qstring.html">QString</a> & href )<tt> [signal]</tt> </h3> <p> This signal is emitted when the user has selected but not activated a link in the document. <em>href</em> is the value of the href tag in the link. <p>Example: <a href="helpviewer-example.html#x1431">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#x1432">helpviewer/helpwindow.cpp</a>. <h3 class=fn>void <a name="keyPressEvent"></a>QTextBrowser::keyPressEvent ( <a href="qkeyevent.html">QKeyEvent</a> * e )<tt> [virtual protected]</tt> </h3> The event <em>e</em> is used to provide the following keyboard shortcuts: <ul> <li><i>Alt+Left Arrow</i> - <a href="#backward">backward</a>() <li><i>Alt+Right Arrow</i> - <a href="#forward">forward</a>() <li><i>Alt+Up Arrow</i> - <a href="#home">home</a>() </ul> <p>Reimplemented from <a href="qtextedit.html#keyPressEvent">QTextEdit</a>. <h3 class=fn>void <a name="linkClicked"></a>QTextBrowser::linkClicked ( const <a href="qstring.html">QString</a> & 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> <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 <a href="qstring.html">QString</a> & name )<tt> [virtual slot]</tt> </h3><p>Sets the name of the currently 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 currently displayed document. See the <a href="qtextbrowser.html#source-prop">"source"</a> property for details. <hr><h2>Property Documentation</h2> <h3 class=fn><a href="qstring.html">QString</a> <a name="source-prop"></a>source</h3> <p>This property holds the name of the currently displayed document. <p>This is a null string if no document is displayed or the source is unknown. <p> Setting this property uses the mimeSourceFactory 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><qt type=detail></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>(). <!-- eof --> <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 <a href="http://www.trolltech.com">Trolltech</a><td><a href="http://www.trolltech.com/trademarks.html">Trademarks</a> <td align=right><div align=right>Qt version 3.0.2</div> </table></div></address></body> </html>