Movatterモバイル変換


[0]ホーム

URL:


We bake cookies in your browser for a better experience. Using this site means that you consent.Read More

Menu

Qt Documentation

QTextDocumentFragment Class

TheQTextDocumentFragment class represents a piece of formatted text from aQTextDocument.More...

Header:#include <QTextDocumentFragment>

Note: All functions in this class arereentrant.

Public Functions

QTextDocumentFragment()
QTextDocumentFragment(const QTextDocument * document)
QTextDocumentFragment(const QTextCursor & cursor)
QTextDocumentFragment(const QTextDocumentFragment & other)
~QTextDocumentFragment()
boolisEmpty() const
QStringtoHtml(const QByteArray & encoding) const
QStringtoHtml() const
QStringtoPlainText() const
QTextDocumentFragment &operator=(const QTextDocumentFragment & other)

Static Public Members

QTextDocumentFragmentfromHtml(const QString & text)
QTextDocumentFragmentfromHtml(const QString & text, const QTextDocument * resourceProvider)
QTextDocumentFragmentfromPlainText(const QString & plainText)

Detailed Description

TheQTextDocumentFragment class represents a piece of formatted text from aQTextDocument.

AQTextDocumentFragment is a fragment of rich text, that can be inserted into aQTextDocument. A document fragment can be created from aQTextDocument, from aQTextCursor's selection, or from another document fragment. Document fragments can also be created by the static functions,fromPlainText() andfromHtml().

The contents of a document fragment can be obtained as plain text by using thetoPlainText() function, or it can be obtained as HTML withtoHtml().

Member Function Documentation

QTextDocumentFragment::QTextDocumentFragment()

Constructs an emptyQTextDocumentFragment.

See alsoisEmpty().

QTextDocumentFragment::QTextDocumentFragment(constQTextDocument * document)

Converts the givendocument into aQTextDocumentFragment. Note that theQTextDocumentFragment only stores the document contents, not meta information like the document's title.

QTextDocumentFragment::QTextDocumentFragment(constQTextCursor & cursor)

Creates aQTextDocumentFragment from thecursor's selection. If the cursor doesn't have a selection, the created fragment is empty.

See alsoisEmpty() andQTextCursor::selection().

QTextDocumentFragment::QTextDocumentFragment(constQTextDocumentFragment & other)

Copy constructor. Creates a copy of theother fragment.

QTextDocumentFragment::~QTextDocumentFragment()

Destroys the document fragment.

[static]QTextDocumentFragment QTextDocumentFragment::fromHtml(constQString & text)

Returns aQTextDocumentFragment based on the arbitrary piece of HTML in the giventext. 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.

[static]QTextDocumentFragment QTextDocumentFragment::fromHtml(constQString & text, constQTextDocument * resourceProvider)

Returns aQTextDocumentFragment based on the arbitrary piece of HTML in the giventext. 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 theresourceProvider.

This function was introduced in Qt 4.2.

[static]QTextDocumentFragment QTextDocumentFragment::fromPlainText(constQString & plainText)

Returns a document fragment that contains the givenplainText.

When inserting such a fragment into aQTextDocument the current char format of theQTextCursor used for insertion is used as format for the text.

bool QTextDocumentFragment::isEmpty() const

Returns true if the fragment is empty; otherwise returns false.

QString QTextDocumentFragment::toHtml(constQByteArray & encoding) const

Returns the contents of the document fragment as HTML, using the specifiedencoding (e.g., "UTF-8", "ISO 8859-1").

This function was introduced in Qt 4.2.

See alsotoPlainText(),QTextDocument::toHtml(), andQTextCodec.

QString QTextDocumentFragment::toHtml() const

This is an overloaded function.

QString QTextDocumentFragment::toPlainText() const

Returns the document fragment's text as plain text (i.e. with no formatting information).

See alsotoHtml().

QTextDocumentFragment & QTextDocumentFragment::operator=(constQTextDocumentFragment & other)

Assigns theother fragment to this fragment.

© 2016 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of theGNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.


[8]ページ先頭

©2009-2025 Movatter.jp