Qt 4.8
|
The QTextDocumentFragment class represents a piece of formatted text from a QTextDocument. More...
#include <qtextdocumentfragment.h>
Public Functions | |
bool | isEmpty () const |
Returns true if the fragment is empty; otherwise returns false. More... | |
QTextDocumentFragment & | operator= (const QTextDocumentFragment &rhs) |
Assigns the other fragment to this fragment. More... | |
QTextDocumentFragment () | |
Constructs an empty QTextDocumentFragment. More... | |
QTextDocumentFragment (const QTextDocument *document) | |
Converts the given document into a QTextDocumentFragment. More... | |
QTextDocumentFragment (const QTextCursor &range) | |
Creates a QTextDocumentFragment from the {cursor}'s selection. More... | |
QTextDocumentFragment (const QTextDocumentFragment &rhs) | |
Copy constructor. More... | |
QString | toHtml () const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More... | |
QString | toHtml (const QByteArray &encoding) const |
Returns the contents of the document fragment as HTML, using the specified encoding (e. More... | |
QString | toPlainText () const |
Returns the document fragment's text as plain text (i.e. More... | |
~QTextDocumentFragment () | |
Destroys the document fragment. More... | |
Static Public Functions | |
static QTextDocumentFragment | fromHtml (const QString &html) |
Returns a QTextDocumentFragment based on the arbitrary piece of HTML in the given text. More... | |
static QTextDocumentFragment | fromHtml (const QString &html, const QTextDocument *resourceProvider) |
static QTextDocumentFragment | fromPlainText (const QString &plainText) |
Returns a document fragment that contains the given plainText. More... | |
Properties | |
QTextDocumentFragmentPrivate * | d |
Friends | |
class | QTextCursor |
class | QTextDocumentWriter |
The QTextDocumentFragment class represents a piece of formatted text from a QTextDocument.
A QTextDocumentFragment is a fragment of rich text, that can be inserted into a QTextDocument. A document fragment can be created from a QTextDocument, from a QTextCursor's selection, or from another document fragment. Document fragments can also be created by the static functions, fromPlainText() and fromHtml().
The contents of a document fragment can be obtained as plain text by using the toPlainText() function, or it can be obtained as HTML with toHtml().
Definition at line 58 of file qtextdocumentfragment.h.
QTextDocumentFragment::QTextDocumentFragment | ( | ) |
Constructs an empty QTextDocumentFragment.
Definition at line 284 of file qtextdocumentfragment.cpp.
|
explicit |
Converts the given document into a QTextDocumentFragment.
Note that the QTextDocumentFragment only stores the document contents, not meta information like the document's title.
Definition at line 294 of file qtextdocumentfragment.cpp.
|
explicit |
Creates a QTextDocumentFragment from the {cursor}'s selection.
If the cursor doesn't have a selection, the created fragment is empty.
Definition at line 311 of file qtextdocumentfragment.cpp.
QTextDocumentFragment::QTextDocumentFragment | ( | const QTextDocumentFragment & | other | ) |
Copy constructor.
Creates a copy of the other fragment.
Definition at line 328 of file qtextdocumentfragment.cpp.
QTextDocumentFragment::~QTextDocumentFragment | ( | ) |
|
static |
Returns a QTextDocumentFragment based on the arbitrary piece of HTML in the given text.
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.
Definition at line 1215 of file qtextdocumentfragment.cpp.
Referenced by QTextControl::insertFromMimeData(), and QTextCursor::insertHtml().
|
static |
Returns a QTextDocumentFragment based on the arbitrary piece of HTML in the given text. 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.
If the provided HTML contains references to external resources such as imported style sheets, then they will be loaded through the resourceProvider.
Definition at line 1233 of file qtextdocumentfragment.cpp.
|
static |
Returns a document fragment that contains the given plainText.
When inserting such a fragment into a QTextDocument the current char format of the QTextCursor used for insertion is used as format for the text.
Definition at line 423 of file qtextdocumentfragment.cpp.
Referenced by QTextControl::insertFromMimeData().
bool QTextDocumentFragment::isEmpty | ( | ) | const |
Returns true if the fragment is empty; otherwise returns false.
Definition at line 365 of file qtextdocumentfragment.cpp.
Referenced by QTextCursor::insertFragment().
QTextDocumentFragment & QTextDocumentFragment::operator= | ( | const QTextDocumentFragment & | rhs | ) |
Assigns the other fragment to this fragment.
Definition at line 343 of file qtextdocumentfragment.cpp.
QString QTextDocumentFragment::toHtml | ( | ) | const |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
Definition at line 391 of file qtextdocumentfragment.cpp.
QString QTextDocumentFragment::toHtml | ( | const QByteArray & | encoding | ) | const |
Returns the contents of the document fragment as HTML, using the specified encoding (e.
g., "UTF-8", "ISO 8859-1").
\sa toPlainText(), QTextDocument::toHtml(), QTextCodec
Definition at line 407 of file qtextdocumentfragment.cpp.
QString QTextDocumentFragment::toPlainText | ( | ) | const |
Returns the document fragment's text as plain text (i.e.
with no formatting information).
Definition at line 376 of file qtextdocumentfragment.cpp.
|
friend |
Definition at line 84 of file qtextdocumentfragment.h.
|
friend |
Definition at line 85 of file qtextdocumentfragment.h.
|
private |
Definition at line 83 of file qtextdocumentfragment.h.
Referenced by fromHtml(), fromPlainText(), QTextCursor::insertFragment(), isEmpty(), operator=(), QTextDocumentFragment(), toHtml(), toPlainText(), QTextDocumentWriter::write(), and ~QTextDocumentFragment().