<?xml version="1.0" encoding="iso-8859-1"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <!-- /tmp/qt-4.3.4-qt-1203442408707/qt-x11-opensource-src-4.3.4/src/gui/text/qtextdocumentfragment.cpp --> <head> <title>Qt 4.3: QTextDocumentFragment Class Reference</title> <link href="classic.css" rel="stylesheet" type="text/css" /> </head> <body> <table border="0" cellpadding="0" cellspacing="0" width="100%"> <tr> <td align="left" valign="top" width="32"><a href="http://www.trolltech.com/products/qt"><img src="images/qt-logo.png" align="left" width="32" height="32" border="0" /></a></td> <td width="1"> </td><td class="postheader" 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="groups.html"><font color="#004faf">Grouped Classes</font></a> · <a href="modules.html"><font color="#004faf">Modules</font></a> · <a href="functions.html"><font color="#004faf">Functions</font></a></td> <td align="right" valign="top" width="230"><a href="http://www.trolltech.com"><img src="images/trolltech-logo.png" align="right" width="203" height="32" border="0" /></a></td></tr></table><h1 align="center">QTextDocumentFragment Class Reference<br /><sup><sup>[<a href="qtgui.html">QtGui</a> module]</sup></sup></h1> <p>The QTextDocumentFragment class represents a piece of formatted text from a <a href="qtextdocument.html">QTextDocument</a>. <a href="#details">More...</a></p> <pre> #include <QTextDocumentFragment></pre><ul> <li><a href="qtextdocumentfragment-members.html">List of all members, including inherited members</a></li> </ul> <a name="public-functions"></a> <h3>Public Functions</h3> <ul> <li><div class="fn"/><b><a href="qtextdocumentfragment.html#QTextDocumentFragment">QTextDocumentFragment</a></b> ()</li> <li><div class="fn"/><b><a href="qtextdocumentfragment.html#QTextDocumentFragment-2">QTextDocumentFragment</a></b> ( const QTextDocument * <i>document</i> )</li> <li><div class="fn"/><b><a href="qtextdocumentfragment.html#QTextDocumentFragment-3">QTextDocumentFragment</a></b> ( const QTextCursor & <i>cursor</i> )</li> <li><div class="fn"/><b><a href="qtextdocumentfragment.html#QTextDocumentFragment-4">QTextDocumentFragment</a></b> ( const QTextDocumentFragment & <i>other</i> )</li> <li><div class="fn"/><b><a href="qtextdocumentfragment.html#dtor.QTextDocumentFragment">~QTextDocumentFragment</a></b> ()</li> <li><div class="fn"/>bool <b><a href="qtextdocumentfragment.html#isEmpty">isEmpty</a></b> () const</li> <li><div class="fn"/>QString <b><a href="qtextdocumentfragment.html#toHtml">toHtml</a></b> ( const QByteArray & <i>encoding</i> ) const</li> <li><div class="fn"/>QString <b><a href="qtextdocumentfragment.html#toHtml-2">toHtml</a></b> () const</li> <li><div class="fn"/>QString <b><a href="qtextdocumentfragment.html#toPlainText">toPlainText</a></b> () const</li> <li><div class="fn"/>QTextDocumentFragment & <b><a href="qtextdocumentfragment.html#operator-eq">operator=</a></b> ( const QTextDocumentFragment & <i>other</i> )</li> </ul> <a name="static-public-members"></a> <h3>Static Public Members</h3> <ul> <li><div class="fn"/>QTextDocumentFragment <b><a href="qtextdocumentfragment.html#fromHtml">fromHtml</a></b> ( const QString & <i>text</i> )</li> <li><div class="fn"/>QTextDocumentFragment <b><a href="qtextdocumentfragment.html#fromHtml-2">fromHtml</a></b> ( const QString & <i>text</i>, const QTextDocument * <i>resourceProvider</i> )</li> <li><div class="fn"/>QTextDocumentFragment <b><a href="qtextdocumentfragment.html#fromPlainText">fromPlainText</a></b> ( const QString & <i>plainText</i> )</li> </ul> <a name="details"></a> <hr /> <h2>Detailed Description</h2> <p>The QTextDocumentFragment class represents a piece of formatted text from a <a href="qtextdocument.html">QTextDocument</a>.</p> <p>A QTextDocumentFragment is a fragment of rich text, that can be inserted into a <a href="qtextdocument.html">QTextDocument</a>. A document fragment can be created from a <a href="qtextdocument.html">QTextDocument</a>, from a <a href="qtextcursor.html">QTextCursor</a>'s selection, or from another document fragment. Document fragments can also be created by the static functions, <a href="qtextdocumentfragment.html#fromPlainText">fromPlainText</a>() and <a href="qtextdocumentfragment.html#fromHtml">fromHtml</a>().</p> <p>The contents of a document fragment can be obtained as plain text by using the <a href="qtextdocumentfragment.html#toPlainText">toPlainText</a>() function, or it can be obtained as HTML with <a href="qtextdocumentfragment.html#toHtml">toHtml</a>().</p> <hr /> <h2>Member Function Documentation</h2> <h3 class="fn"><a name="QTextDocumentFragment"></a>QTextDocumentFragment::QTextDocumentFragment ()</h3> <p>Constructs an empty <a href="qtextdocumentfragment.html">QTextDocumentFragment</a>.</p> <p>See also <a href="qtextdocumentfragment.html#isEmpty">isEmpty</a>().</p> <h3 class="fn"><a name="QTextDocumentFragment-2"></a>QTextDocumentFragment::QTextDocumentFragment ( const <a href="qtextdocument.html">QTextDocument</a> * <i>document</i> )</h3> <p>Converts the given <i>document</i> into a <a href="qtextdocumentfragment.html">QTextDocumentFragment</a>. Note that the <a href="qtextdocumentfragment.html">QTextDocumentFragment</a> only stores the document contents, not meta information like the document's title.</p> <h3 class="fn"><a name="QTextDocumentFragment-3"></a>QTextDocumentFragment::QTextDocumentFragment ( const <a href="qtextcursor.html">QTextCursor</a> & <i>cursor</i> )</h3> <p>Creates a <a href="qtextdocumentfragment.html">QTextDocumentFragment</a> from the <i>cursor</i>'s selection. If the cursor doesn't have a selection, the created fragment is empty.</p> <p>See also <a href="qtextdocumentfragment.html#isEmpty">isEmpty</a>() and <a href="qtextcursor.html#selection">QTextCursor::selection</a>().</p> <h3 class="fn"><a name="QTextDocumentFragment-4"></a>QTextDocumentFragment::QTextDocumentFragment ( const QTextDocumentFragment & <i>other</i> )</h3> <p>Copy constructor. Creates a copy of the <i>other</i> fragment.</p> <h3 class="fn"><a name="dtor.QTextDocumentFragment"></a>QTextDocumentFragment::~QTextDocumentFragment ()</h3> <p>Destroys the document fragment.</p> <h3 class="fn"><a name="fromHtml"></a>QTextDocumentFragment QTextDocumentFragment::fromHtml ( const <a href="qstring.html">QString</a> & <i>text</i> ) <tt> [static]</tt></h3> <p>Returns a <a href="qtextdocumentfragment.html">QTextDocumentFragment</a> based on the arbitrary piece of HTML in the given <i>text</i>. The formatting is preserved as much as possible; for example, "<b>bold</b>" will become a document fragment with the text "bold" with a bold character format.</p> <h3 class="fn"><a name="fromHtml-2"></a>QTextDocumentFragment QTextDocumentFragment::fromHtml ( const <a href="qstring.html">QString</a> & <i>text</i>, const <a href="qtextdocument.html">QTextDocument</a> * <i>resourceProvider</i> ) <tt> [static]</tt></h3> <p>This is an overloaded member function, provided for convenience.</p> <p>Returns a <a href="qtextdocumentfragment.html">QTextDocumentFragment</a> based on the arbitrary piece of HTML in the given <i>text</i>. The formatting is preserved as much as possible; for example, "<b>bold</b>" will become a document fragment with the text "bold" with a bold character format.</p> <p>If the provided HTML contains references to external resources such as imported style sheets, then they will be loaded through the <i>resourceProvider</i>.</p> <p>This function was introduced in Qt 4.2.</p> <h3 class="fn"><a name="fromPlainText"></a>QTextDocumentFragment QTextDocumentFragment::fromPlainText ( const <a href="qstring.html">QString</a> & <i>plainText</i> ) <tt> [static]</tt></h3> <p>Returns a document fragment that contains the given <i>plainText</i>.</p> <p>When inserting such a fragment into a <a href="qtextdocument.html">QTextDocument</a> the current char format of the <a href="qtextcursor.html">QTextCursor</a> used for insertion is used as format for the text.</p> <h3 class="fn"><a name="isEmpty"></a>bool QTextDocumentFragment::isEmpty () const</h3> <p>Returns true if the fragment is empty; otherwise returns false.</p> <h3 class="fn"><a name="toHtml"></a><a href="qstring.html">QString</a> QTextDocumentFragment::toHtml ( const <a href="qbytearray.html">QByteArray</a> & <i>encoding</i> ) const</h3> <p>Returns the contents of the document fragment as HTML, using the specified <i>encoding</i> (e.g., "UTF-8", "ISO 8859-1").</p> <p>This function was introduced in Qt 4.2.</p> <p>See also <a href="qtextdocumentfragment.html#toPlainText">toPlainText</a>(), <a href="qtextdocument.html#toHtml">QTextDocument::toHtml</a>(), and <a href="qtextcodec.html">QTextCodec</a>.</p> <h3 class="fn"><a name="toHtml-2"></a><a href="qstring.html">QString</a> QTextDocumentFragment::toHtml () const</h3> <p>This is an overloaded member function, provided for convenience.</p> <h3 class="fn"><a name="toPlainText"></a><a href="qstring.html">QString</a> QTextDocumentFragment::toPlainText () const</h3> <p>Returns the document fragment's text as plain text (i.e. with no formatting information).</p> <p>See also <a href="qtextdocumentfragment.html#toHtml">toHtml</a>().</p> <h3 class="fn"><a name="operator-eq"></a>QTextDocumentFragment & QTextDocumentFragment::operator= ( const QTextDocumentFragment & <i>other</i> )</h3> <p>Assigns the <i>other</i> fragment to this fragment.</p> <p /><address><hr /><div align="center"> <table width="100%" cellspacing="0" border="0"><tr class="address"> <td width="30%">Copyright © 2008 <a href="trolltech.html">Trolltech</a></td> <td width="40%" align="center"><a href="trademarks.html">Trademarks</a></td> <td width="30%" align="right"><div align="right">Qt 4.3.4</div></td> </tr></table></div></address></body> </html>