QTextEdit

QTextEdit class provides a widget that is used to edit and display both plain and rich text. 更多

Inheritance diagram of PySide2.QtWidgets.QTextEdit

继承者: QTextBrowser

概要

函数

详细描述

介绍和概念

QTextEdit is an advanced WYSIWYG viewer/editor supporting rich text formatting using HTML-style tags, or Markdown format. It is optimized to handle large documents and to respond quickly to user input.

QTextEdit works on paragraphs and characters. A paragraph is a formatted string which is word-wrapped to fit into the width of the widget. By default when reading plain text, one newline signifies a paragraph. A document consists of zero or more paragraphs. The words in the paragraph are aligned in accordance with the paragraph’s alignment. Paragraphs are separated by hard line breaks. Each character within a paragraph has its own attributes, for example, font and color.

QTextEdit can display images, lists and tables. If the text is too large to view within the text edit’s viewport, scroll bars will appear. The text edit can load both plain text and rich text files. Rich text can be described using a subset of HTML 4 markup; refer to the 支持的 HTML 子集 页面,了解更多信息。

若仅仅需要显示小段富文本使用 QLabel .

Qt 中的富文本支持旨在为向应用程序添加合理在线帮助设施提供快速、可移植、有效手段,并为富文本编辑器提供基础。若发现 HTML 支持不足以满足需求,可以考虑使用 Qt WebKit,它提供了功能齐全的 Web 浏览器 Widget。

The shape of the mouse cursor on a QTextEdit is IBeamCursor 默认情况下。它可以被改变透过 viewport() ‘s cursor property.

使用 QTextEdit 作为显示 Widget

QTextEdit can display a large HTML subset, including tables and images.

可以设置或替换文本使用 setHtml() which deletes any existing text and replaces it with the text passed in the setHtml() call. If you call setHtml() with legacy HTML, and then call toHtml() , the text that is returned may have different markup, but will render the same. The entire text can be deleted with clear() .

还可以设置或替换文本使用 setMarkdown() , and the same caveats apply: if you then call toMarkdown() , the text that is returned may be different, but the meaning is preserved as much as possible. Markdown with some embedded HTML can be parsed, with the same limitations that setHtml() has; but toMarkdown() only writes “pure” Markdown, without any embedded HTML.

可以插入文字本身使用 QTextCursor 类或使用方便函数 insertHtml() , insertPlainText() , append() or paste() . QTextCursor 还能够把复杂对象 (像:表格或列表) 插入文档,且它能够处理创建选择并将改变应用到选中文本。

默认情况下,文本编辑在空白处自动换行以拟合在文本编辑 Widget 中。 setLineWrapMode() function is used to specify the kind of line wrap you want, or NoWrap if you don’t want any wrapping. Call setLineWrapMode() to set a fixed pixel width FixedPixelWidth ,或字符列 (如:80 列) FixedColumnWidth 按指定像素或列数采用 setLineWrapColumnOrWidth() . If you use word wrap to the widget’s width WidgetWidth ,可以指定是在空白处断开还是在任何地方断开采用 setWordWrapMode() .

find() function can be used to find and select a given string within the text.

If you want to limit the total number of paragraphs in a QTextEdit , as for example it is often useful in a log viewer, then you can use QTextDocument ‘s maximumBlockCount property for that.

只读键绑定

QTextEdit is used read-only the key bindings are limited to navigation, and text may only be selected with the mouse:

Keypresses

Action

Up

向上移动一行。

Down

向下移动一行。

Left

向左移动一字符。

Right

向右移动一字符。

PageUp

向上移动一 (视口) 页。

PageDown

向下移动一 (视口) 页。

首页

移动到文本的起始。

End

移动到文本的结尾。

Alt+Wheel

水平卷动页面 (Wheel 是鼠标滚轮)。

Ctrl+Wheel

缩放文本。

Ctrl+A

选择所有文本。

文本编辑可能能够提供一些元信息。例如, documentTitle() function will return the text from within HTML <title> 标签。

注意

缩放 HTML 文档才工作,若字体尺寸未设为固定大小。

使用 QTextEdit 作为编辑器

All the information about using QTextEdit as a display widget also applies here.

The current char format’s attributes are set with setFontItalic() , setFontWeight() , setFontUnderline() , setFontFamily() , setFontPointSize() , setTextColor() and setCurrentFont() . The current paragraph’s alignment is set with setAlignment() .

文本选择的处理通过 QTextCursor 类,提供创建选择、检索文本内容或删除选定的功能。可以检索对应用户可见光标的对象使用 textCursor() method. If you want to set a selection in QTextEdit just create one on a QTextCursor 对象然后使该光标成为可见光标使用 setTextCursor() . The selection can be copied to the clipboard with copy() , or cut to the clipboard with cut() . The entire text can be selected using selectAll() .

当光标被移动且底层格式化属性改变时, currentCharFormatChanged() signal is emitted to reflect the new attributes at the new cursor position.

textChanged() signal is emitted whenever the text changes (as a result of setText() or through the editor itself).

QTextEdit holds a QTextDocument 对象,可以被检索使用 document() method. You can also set your own document object using setDocument() .

QTextDocument 提供 isModified() 函数,返回 true 若文本在加载或采用 false 作为自变量最后调用 setModified 后被修改。此外,它提供撤消和重做方法。

拖放

QTextEdit also supports custom drag and drop behavior. By default, QTextEdit will insert plain text, HTML and rich text when the user drops data of these MIME types onto a document. Reimplement canInsertFromMimeData() and insertFromMimeData() to add support for additional MIME types.

For example, to allow the user to drag and drop an image onto a QTextEdit , you could the implement these functions in the following way:

bool TextEdit::canInsertFromMimeData( const QMimeData *source ) const
{
    if (source->hasImage())
        return true;
    else
        return QTextEdit::canInsertFromMimeData(source);
}
												

通过返回 true 添加对图像 MIME 类型的支持。对于所有其它 MIME 类型,使用默认实现。

void TextEdit::insertFromMimeData( const QMimeData *source )
{
    if (source->hasImage())
    {
        QImage image = qvariant_cast<QImage>(source->imageData());
        QTextCursor cursor = this->textCursor();
        QTextDocument *document = this->document();
        document->addResource(QTextDocument::ImageResource, QUrl("image"), image);
        cursor.insertImage("image");
    }
}
												

解包图像从 QVariant 保持通过 MIME 源并把它作为资源插入文档。

编辑键绑定

为编辑而实现的键绑定列表:

Keypresses

Action

Backspace

删除光标左侧字符。

Delete

删除光标右侧字符。

Ctrl+C

把选中文本拷贝到剪贴板。

Ctrl+Insert

把选中文本拷贝到剪贴板。

Ctrl+K

删除到行尾。

Ctrl+V

把剪贴板文本粘贴到文本编辑中。

Shift+Insert

把剪贴板文本粘贴到文本编辑中。

Ctrl+X

删除选中文本并把它拷贝到剪贴板。

Shift+Delete

删除选中文本并把它拷贝到剪贴板。

Ctrl+Z

撤消上一操作。

Ctrl+Y

重做上一操作。

Left

左移光标一字符。

Ctrl+Left

把光标左移一单词。

Right

右移光标一字符。

Ctrl+Right

把光标右移一单词。

Up

上移光标一行。

Down

下移光标一行。

PageUp

把光标上移一页。

PageDown

把光标下移一页。

首页

把光标移到行开头。

Ctrl+Home

把光标移到文本开头。

End

把光标移到行尾。

Ctrl+End

把光标移到文本末尾。

Alt+Wheel

水平卷动页面 (Wheel 是鼠标滚轮)。

要选择 (标记) 文本,在按住 Shift 键的同时按下某一移动按键,例如, Shift+Right 将选择右侧字符,而 Shift+Ctrl+Right 将选择右侧单词,等等。

class QTextEdit ( [ parent=None ] )

QTextEdit(text[, parent=None])

param parent

QWidget

param text

unicode

构造空 QTextEdit 采用父级 parent .

PySide2.QtWidgets.QTextEdit. LineWrapMode

常量

描述

QTextEdit.NoWrap

QTextEdit.WidgetWidth

QTextEdit.FixedPixelWidth

QTextEdit.FixedColumnWidth

PySide2.QtWidgets.QTextEdit. AutoFormattingFlag

常量

描述

QTextEdit.AutoNone

Don’t do any automatic formatting.

QTextEdit.AutoBulletList

Automatically create bullet lists (e.g. when the user enters an asterisk (‘*’) in the left most column, or presses Enter in an existing list item.

QTextEdit.AutoAll

应用所有自动格式。目前仅支持自动项目符号列表。

PySide2.QtWidgets.QTextEdit. acceptRichText ( )
返回类型

bool

PySide2.QtWidgets.QTextEdit. alignment ( )
返回类型

Alignment

返回当前段落的对齐方式。

另请参阅

setAlignment()

PySide2.QtWidgets.QTextEdit. anchorAt ( pos )
参数

pos QPoint

返回类型

unicode

返回锚点引用在位置 pos ,或空字符串若该点不存在锚点。

PySide2.QtWidgets.QTextEdit. append ( text )
参数

text – unicode

追加新段落采用 text 到文本编辑末尾。

注意

The new paragraph appended will have the same character format and block format as the current paragraph, determined by the position of the cursor.

另请参阅

currentCharFormat() blockFormat()

PySide2.QtWidgets.QTextEdit. autoFormatting ( )
返回类型

AutoFormatting

PySide2.QtWidgets.QTextEdit. canInsertFromMimeData ( source )
参数

source QMimeData

返回类型

bool

此函数返回 true if the contents of the MIME data object, specified by source , can be decoded and inserted into the document. It is called for example when during a drag operation the mouse enters this widget and it is necessary to determine whether it is possible to accept the drag and drop operation.

重新实现此函数以启用对额外 MIME 类型的拖放支持。

PySide2.QtWidgets.QTextEdit. canPaste ( )
返回类型

bool

返回是否可以把文本从剪贴板粘贴到 textedit。

PySide2.QtWidgets.QTextEdit. clear ( )

删除文本编辑中的所有文本。

注意事项:

PySide2.QtWidgets.QTextEdit. copy ( )

把任何选中文本拷贝到剪贴板。

另请参阅

copyAvailable()

PySide2.QtWidgets.QTextEdit. copyAvailable ( b )
参数

b bool

PySide2.QtWidgets.QTextEdit. createMimeDataFromSelection ( )
返回类型

QMimeData

This function returns a new MIME data object to represent the contents of the text edit’s current selection. It is called when the selection needs to be encapsulated into a new QMimeData object; for example, when a drag and drop operation is started, or when data is copied to the clipboard.

If you reimplement this function, note that the ownership of the returned QMimeData object is passed to the caller. The selection can be retrieved by using the textCursor() 函数。

PySide2.QtWidgets.QTextEdit. createStandardContextMenu ( )
返回类型

QMenu

此函数创建要展示的标准上下文菜单,当用户采用鼠标右键点击文本编辑时。它被调用从默认 contextMenuEvent() handler. The popup menu’s ownership is transferred to the caller.

We recommend that you use the ( QPoint ) 版本,启用用户点击位置敏感动作。

PySide2.QtWidgets.QTextEdit. createStandardContextMenu ( position )
参数

position QPoint

返回类型

QMenu

此函数创建要展示的标准上下文菜单,当用户采用鼠标右键点击文本编辑时。它被调用从默认 contextMenuEvent() handler and it takes the position in document coordinates where the mouse click was. This can enable actions that are sensitive to the position where the user clicked. The popup menu’s ownership is transferred to the caller.

PySide2.QtWidgets.QTextEdit. currentCharFormat ( )
返回类型

QTextCharFormat

返回插入新文本时使用的字符格式。

PySide2.QtWidgets.QTextEdit. currentCharFormatChanged ( format )
参数

format QTextCharFormat

PySide2.QtWidgets.QTextEdit. currentFont ( )
返回类型

QFont

返回当前格式的字体。

PySide2.QtWidgets.QTextEdit. cursorForPosition ( pos )
参数

pos QPoint

返回类型

QTextCursor

返回 QTextCursor 在位置 pos (在视口坐标中)。

PySide2.QtWidgets.QTextEdit. cursorPositionChanged ( )
PySide2.QtWidgets.QTextEdit. cursorRect ( )
返回类型

QRect

返回包括文本编辑光标的矩形 (在视口坐标中)。

PySide2.QtWidgets.QTextEdit. cursorRect ( cursor )
参数

cursor QTextCursor

返回类型

QRect

返回矩形 (在视口坐标中) 包括 cursor .

PySide2.QtWidgets.QTextEdit. cursorWidth ( )
返回类型

int

另请参阅

setCursorWidth()

PySide2.QtWidgets.QTextEdit. cut ( )

把选中文本拷贝到剪贴板,并将其从文本编辑中删除。

若没有选中文本,什么都不发生。

另请参阅

copy() paste()

PySide2.QtWidgets.QTextEdit. doSetTextCursor ( cursor )
参数

cursor QTextCursor

This provides a hook for subclasses to intercept cursor changes.

PySide2.QtWidgets.QTextEdit. document ( )
返回类型

QTextDocument

另请参阅

setDocument()

PySide2.QtWidgets.QTextEdit. documentTitle ( )
返回类型

unicode

PySide2.QtWidgets.QTextEdit. ensureCursorVisible ( )

通过卷动文本编辑确保光标是可见的,若有必要。

PySide2.QtWidgets.QTextEdit. extraSelections ( )
返回类型

返回先前设置的额外选定。

PySide2.QtWidgets.QTextEdit. find ( exp [ , options=QTextDocument.FindFlags() ] )
参数
  • exp QRegularExpression

  • options FindFlags

返回类型

bool

PySide2.QtWidgets.QTextEdit. find ( exp [ , options=QTextDocument.FindFlags() ] )
参数
  • exp QRegExp

  • options FindFlags

返回类型

bool

PySide2.QtWidgets.QTextEdit. find ( exp [ , options=QTextDocument.FindFlags() ] )
参数
  • exp – unicode

  • options FindFlags

返回类型

bool

PySide2.QtWidgets.QTextEdit. fontFamily ( )
返回类型

unicode

返回当前格式的字体系列。

PySide2.QtWidgets.QTextEdit. fontItalic ( )
返回类型

bool

返回 true 若当前格式的字体是斜体;否则返回 false。

另请参阅

setFontItalic()

PySide2.QtWidgets.QTextEdit. fontPointSize ( )
返回类型

qreal

返回当前格式字体的点尺寸。

PySide2.QtWidgets.QTextEdit. fontUnderline ( )
返回类型

bool

返回 true 若当前格式字体带下划线;否则返回 false。

PySide2.QtWidgets.QTextEdit. fontWeight ( )
返回类型

int

返回当前格式的字体权重。

PySide2.QtWidgets.QTextEdit. inputMethodQuery ( query , argument )
参数
  • query InputMethodQuery

  • argument – object

返回类型

object

PySide2.QtWidgets.QTextEdit. insertFromMimeData ( source )
参数

source QMimeData

This function inserts the contents of the MIME data object, specified by source , into the text edit at the current cursor position. It is called whenever text is inserted as the result of a clipboard paste operation, or when the text edit accepts data from a drag and drop operation.

重新实现此函数以启用对额外 MIME 类型的拖放支持。

PySide2.QtWidgets.QTextEdit. insertHtml ( text )
参数

text – unicode

方便槽,插入 text which is assumed to be of html formatting at the current cursor position.

相当于:

edit.textCursor().insertHtml(fragment)
												

注意

When using this function with a style sheet, the style sheet will only apply to the current block in the document. In order to apply a style sheet throughout a document, use setDefaultStyleSheet() 代替。

PySide2.QtWidgets.QTextEdit. insertPlainText ( text )
参数

text – unicode

方便槽,插入 text 在当前光标位置。

它相当于

edit.textCursor().insertText(text)
												
PySide2.QtWidgets.QTextEdit. isReadOnly ( )
返回类型

bool

PySide2.QtWidgets.QTextEdit. isUndoRedoEnabled ( )
返回类型

bool

PySide2.QtWidgets.QTextEdit. lineWrapColumnOrWidth ( )
返回类型

int

PySide2.QtWidgets.QTextEdit. lineWrapMode ( )
返回类型

LineWrapMode

另请参阅

setLineWrapMode()

PySide2.QtWidgets.QTextEdit. loadResource ( type , name )
参数
  • type int

  • name QUrl

返回类型

object

加载指定资源通过给定 type and name .

This function is an extension of loadResource() .

另请参阅

loadResource()

PySide2.QtWidgets.QTextEdit. mergeCurrentCharFormat ( modifier )
参数

modifier QTextCharFormat

Merges the properties specified in modifier into the current character format by calling mergeCharFormat on the editor’s cursor. If the editor has a selection then the properties of modifier are directly applied to the selection.

另请参阅

mergeCharFormat()

PySide2.QtWidgets.QTextEdit. moveCursor ( operation [ , mode=QTextCursor.MoveAnchor ] )
参数
  • operation MoveOperation

  • mode MoveMode

移动光标通过履行给定 operation .

mode is KeepAnchor ,光标选择由它移动覆盖的文本。这与用户达成的效果相同,当按下 Shift 键和采用光标键移动光标时。

另请参阅

movePosition()

PySide2.QtWidgets.QTextEdit. overwriteMode ( )
返回类型

bool

PySide2.QtWidgets.QTextEdit. paste ( )

把剪贴板文本粘贴到文本编辑当前光标位置处。

若剪贴板中没有文本,什么都不发生。

To change the behavior of this function, i.e. to modify what QTextEdit can paste and how it is being pasted, reimplement the virtual canInsertFromMimeData() and insertFromMimeData() 函数。

另请参阅

cut() copy()

PySide2.QtWidgets.QTextEdit. placeholderText ( )
返回类型

unicode

PySide2.QtWidgets.QTextEdit. print_ ( printer )
参数

printer QPagedPaintDevice

Convenience function to print the text edit’s document to the given printer . This is equivalent to calling the print method on the document directly except that this function also supports Selection as print range.

另请参阅

print()

PySide2.QtWidgets.QTextEdit. redo ( )

重做上一操作。

If there is no operation to redo, i.e. there is no redo step in the undo/redo history, nothing happens.

另请参阅

undo()

PySide2.QtWidgets.QTextEdit. redoAvailable ( b )
参数

b bool

PySide2.QtWidgets.QTextEdit. scrollToAnchor ( name )
参数

name – unicode

Scrolls the text edit so that the anchor with the given name is visible; does nothing if the name is empty, or is already visible, or isn’t found.

PySide2.QtWidgets.QTextEdit. selectAll ( )

选择所有文本。

PySide2.QtWidgets.QTextEdit. selectionChanged ( )
PySide2.QtWidgets.QTextEdit. setAcceptRichText ( accept )
参数

accept bool

另请参阅

acceptRichText()

PySide2.QtWidgets.QTextEdit. setAlignment ( a )
参数

a Alignment

把当前段落的对齐方式设为 a 。有效对齐方式是 AlignLeft , AlignRight , AlignJustify and AlignCenter (水平居中)。

另请参阅

alignment()

PySide2.QtWidgets.QTextEdit. setAutoFormatting ( features )
参数

features AutoFormatting

另请参阅

autoFormatting()

PySide2.QtWidgets.QTextEdit. setCurrentCharFormat ( format )
参数

format QTextCharFormat

把新文本插入时使用的字符格式设为 format 通过调用 setCharFormat() on the editor’s cursor. If the editor has a selection then the char format is directly applied to the selection.

PySide2.QtWidgets.QTextEdit. setCurrentFont ( f )
参数

f QFont

把当前格式的字体设为 f .

PySide2.QtWidgets.QTextEdit. setCursorWidth ( width )
参数

width int

另请参阅

cursorWidth()

PySide2.QtWidgets.QTextEdit. setDocument ( document )
参数

document QTextDocument

另请参阅

document()

PySide2.QtWidgets.QTextEdit. setDocumentTitle ( title )
参数

title – unicode

另请参阅

documentTitle()

PySide2.QtWidgets.QTextEdit. setExtraSelections ( selections )
参数

selections

此函数允许采用给定颜色临时标记某些文档区域,指定通过 selections 。例如:这在编程编辑器中可以是有用的,采用给定背景颜色标记整行文本以指示断点的存在。

另请参阅

ExtraSelection extraSelections()

PySide2.QtWidgets.QTextEdit. setFontFamily ( fontFamily )
参数

fontFamily – unicode

把当前格式的字体系列设为 fontFamily .

PySide2.QtWidgets.QTextEdit. setFontItalic ( b )
参数

b bool

italic is true, sets the current format to italic; otherwise sets the current format to non-italic.

另请参阅

fontItalic()

PySide2.QtWidgets.QTextEdit. setFontPointSize ( s )
参数

s qreal

将当前格式的点尺寸设为 s .

注意:若 s is zero or negative, the behavior of this function is not defined.

PySide2.QtWidgets.QTextEdit. setFontUnderline ( b )
参数

b bool

underline is true, sets the current format to underline; otherwise sets the current format to non-underline.

另请参阅

fontUnderline()

PySide2.QtWidgets.QTextEdit. setFontWeight ( w )
参数

w int

Sets the font weight of the current format to the given weight , where the value used is in the range defined by the Weight 枚举。

PySide2.QtWidgets.QTextEdit. setHtml ( text )
参数

text – unicode

PySide2.QtWidgets.QTextEdit. setLineWrapColumnOrWidth ( w )
参数

w int

PySide2.QtWidgets.QTextEdit. setLineWrapMode ( mode )
参数

mode LineWrapMode

另请参阅

lineWrapMode()

PySide2.QtWidgets.QTextEdit. setMarkdown ( markdown )
参数

markdown – unicode

PySide2.QtWidgets.QTextEdit. setOverwriteMode ( overwrite )
参数

overwrite bool

另请参阅

overwriteMode()

PySide2.QtWidgets.QTextEdit. setPlaceholderText ( placeholderText )
参数

placeholderText – unicode

另请参阅

placeholderText()

PySide2.QtWidgets.QTextEdit. setPlainText ( text )
参数

text – unicode

把文本编辑的文本更改为字符串 text 。移除任何以前文本。

注意事项:

另请参阅

toPlainText()

PySide2.QtWidgets.QTextEdit. setReadOnly ( ro )
参数

ro bool

另请参阅

isReadOnly()

PySide2.QtWidgets.QTextEdit. setTabChangesFocus ( b )
参数

b bool

另请参阅

tabChangesFocus()

PySide2.QtWidgets.QTextEdit. setTabStopDistance ( distance )
参数

distance qreal

另请参阅

tabStopDistance()

PySide2.QtWidgets.QTextEdit. setTabStopWidth ( width )
参数

width int

注意

此函数被弃用。

另请参阅

tabStopWidth()

PySide2.QtWidgets.QTextEdit. setText ( text )
参数

text – unicode

Sets the text edit’s text . The text can be plain text or HTML and the text edit will try to guess the right format.

使用 setHtml() or setPlainText() directly to avoid text edit’s guessing.

PySide2.QtWidgets.QTextEdit. setTextBackgroundColor ( c )
参数

c QColor

把当前格式的文本背景颜色设为 c .

PySide2.QtWidgets.QTextEdit. setTextColor ( c )
参数

c QColor

把当前格式的文本颜色设为 c .

另请参阅

textColor()

PySide2.QtWidgets.QTextEdit. setTextCursor ( cursor )
参数

cursor QTextCursor

设置可见 cursor .

另请参阅

textCursor()

PySide2.QtWidgets.QTextEdit. setTextInteractionFlags ( flags )
参数

flags TextInteractionFlags

PySide2.QtWidgets.QTextEdit. setUndoRedoEnabled ( enable )
参数

enable bool

PySide2.QtWidgets.QTextEdit. setWordWrapMode ( policy )
参数

policy WrapMode

另请参阅

wordWrapMode()

PySide2.QtWidgets.QTextEdit. tabChangesFocus ( )
返回类型

bool

PySide2.QtWidgets.QTextEdit. tabStopDistance ( )
返回类型

qreal

PySide2.QtWidgets.QTextEdit. tabStopWidth ( )
返回类型

int

注意

此函数被弃用。

另请参阅

setTabStopWidth()

PySide2.QtWidgets.QTextEdit. textBackgroundColor ( )
返回类型

QColor

返回当前格式的文本背景颜色。

PySide2.QtWidgets.QTextEdit. textChanged ( )
PySide2.QtWidgets.QTextEdit. textColor ( )
返回类型

QColor

返回当前格式的文本颜色。

另请参阅

setTextColor()

PySide2.QtWidgets.QTextEdit. textCursor ( )
返回类型

QTextCursor

返回副本为 QTextCursor 表示当前可见光标。注意:改变返回光标不影响 QTextEdit ‘s cursor; use setTextCursor() to update the visible cursor.

另请参阅

setTextCursor()

PySide2.QtWidgets.QTextEdit. textInteractionFlags ( )
返回类型

TextInteractionFlags

PySide2.QtWidgets.QTextEdit. toHtml ( )
返回类型

unicode

PySide2.QtWidgets.QTextEdit. toMarkdown ( [ features=QTextDocument.MarkdownDialectGitHub ] )
参数

features MarkdownFeatures

返回类型

unicode

PySide2.QtWidgets.QTextEdit. toPlainText ( )
返回类型

unicode

QString const

把文本编辑的文本作为纯文本返回。

另请参阅

setPlainText()

PySide2.QtWidgets.QTextEdit. undo ( )

撤消上一操作。

若没有要撤消的操作 (即:撤消/重做历史中没有撤消步骤),什么都不发生。

另请参阅

redo()

PySide2.QtWidgets.QTextEdit. undoAvailable ( b )
参数

b bool

PySide2.QtWidgets.QTextEdit. wordWrapMode ( )
返回类型

WrapMode

另请参阅

setWordWrapMode()

PySide2.QtWidgets.QTextEdit. zoomIn ( [ range=1 ] )
参数

range int

Zooms in on the text by making the base font size range points larger and recalculating all font sizes to be the new size. This does not change the size of any images.

另请参阅

zoomOut()

PySide2.QtWidgets.QTextEdit. zoomInF ( range )
参数

range float

PySide2.QtWidgets.QTextEdit. zoomOut ( [ range=1 ] )
参数

range int

Zooms out on the text by making the base font size range points smaller and recalculating all font sizes to be the new size. This does not change the size of any images.

另请参阅

zoomIn()