QTextDocumentFragment Class Reference

[QtGui module]

该QTextDocumentFragment类表示了一块格式化文本从一个QTextDocumentMore…

Methods

  • __init__ (self)
  • __init__ (self, QTextDocument document)
  • __init__ (self, QTextCursor range)
  • __init__ (self, QTextDocumentFragment rhs)
  • bool isEmpty (self)
  • QString toHtml (self)
  • QString toHtml (self, QByteArray encoding)
  • QString toPlainText (self)

Static Methods

  • QTextDocumentFragment fromHtml (QString html)
  • QTextDocumentFragment fromHtml (QString html, QTextDocument resourceProvider)
  • QTextDocumentFragment fromPlainText (QString plainText)

Detailed Description

该QTextDocumentFragment类表示了一块格式化文本从一个QTextDocument

一个QTextDocumentFragment是富文本的一个片段,可以插入到QTextDocument。文档片段可以从被创建QTextDocument,从QTextCursor的选择,或从另一个文件片段。文件的片段,也可以通过静态函数创建的,fromPlainText()和fromHtml( ) 。

文档片段的内容可以通过使用获得以纯文本的toPlainText()函数,或者它可以得到的HTMLtoHtml( ) 。


Method Documentation

  1. QTextDocumentFragment.__init__ (self)

构造一个空QTextDocumentFragment

See also isEmpty( ) 。

  1. QTextDocumentFragment.__init__ (self, QTextDocument document)

转换给定的documentQTextDocumentFragment。注意,这个QTextDocumentFragment只存储文件内容,而不是像文档的标题的元信息。

  1. QTextDocumentFragment.__init__ (self, QTextCursor range)

创建QTextDocumentFragmentcursor的选择。如果光标没有选择,创建​​片段是空的。

See also isEmpty()和QTextCursor.selection( ) 。

  1. QTextDocumentFragment.__init__ (self, QTextDocumentFragment rhs)

拷贝构造函数。创建的副本other片段。

  1. QTextDocumentFragment QTextDocumentFragment.fromHtml (QString html)

返回QTextDocumentFragment根据任意一块的HTML中的给定text。该格式被保留尽可能多的,例如, “ \u003cb\u003e粗体\u003c / B\u003e ”将成为一个文档片段与文本“大胆”的一个大胆的字符格式。

  1. QTextDocumentFragment QTextDocumentFragment.fromHtml (QString html, QTextDocument resourceProvider)

返回QTextDocumentFragment根据任意一块的HTML中的给定text。该格式被保留尽可能多的,例如, “ \u003cb\u003e粗体\u003c / B\u003e ”将成为一个文档片段与文本“大胆”的一个大胆的字符格式。

如果所提供的HTML包含引用外部资源,如导入的样式表,那么他们将通过加载resourceProvider

这个函数中引入了Qt 4.2中。

  1. QTextDocumentFragment QTextDocumentFragment.fromPlainText (QString plainText)

[

返回包含给定一个文档片段plainText

]($docs-qtextdocumentfragment.html)

当插入这样一个片段成QTextDocument的当前字符格式QTextCursor用于插入被用作文本格式。

  1. bool QTextDocumentFragment.isEmpty (self)

返回True如果该片段为空,否则返回False 。

  1. QString QTextDocumentFragment.toHtml (self)

返回文档片段的内容作为HTML,使用指定的encoding(例如, “UTF- 8”,“ ISO 8859 ” ) 。

这个函数中引入了Qt 4.2中。

See also toPlainText( )QTextDocument.toHtml()和QTextCodec

  1. QString QTextDocumentFragment.toHtml (self, QByteArray encoding)

这是一个重载函数。

  1. QString QTextDocumentFragment.toPlainText (self)

返回文档片段的文字为纯文本(即不带格式信息) 。

See also toHtml( ) 。