继承者: QTextBrowser
def
acceptRichText
()
def
alignment
()
def
anchorAt
(pos)
def
autoFormatting
()
def
canPaste
()
def
createStandardContextMenu
()
def
createStandardContextMenu
(position)
def
currentCharFormat
()
def
currentFont
()
def
cursorForPosition
(pos)
def
cursorRect
()
def
cursorRect
(cursor)
def
cursorWidth
()
def
document
()
def
documentTitle
()
def
ensureCursorVisible
()
def
extraSelections
()
def
find
(exp[, options=QTextDocument.FindFlags()])
def
find
(exp[, options=QTextDocument.FindFlags()])
def
find
(exp[, options=QTextDocument.FindFlags()])
def
fontFamily
()
def
fontItalic
()
def
fontPointSize
()
def
fontUnderline
()
def
fontWeight
()
def
inputMethodQuery
(query, argument)
def
isReadOnly
()
def
isUndoRedoEnabled
()
def
lineWrapColumnOrWidth
()
def
lineWrapMode
()
def
mergeCurrentCharFormat
(modifier)
def
moveCursor
(operation[, mode=QTextCursor.MoveAnchor])
def
overwriteMode
()
def
placeholderText
()
def
print_
(printer)
def
setAcceptRichText
(accept)
def
setAutoFormatting
(features)
def
setCurrentCharFormat
(format)
def
setCursorWidth
(width)
def
setDocument
(document)
def
setDocumentTitle
(title)
def
setExtraSelections
(selections)
def
setLineWrapColumnOrWidth
(w)
def
setLineWrapMode
(mode)
def
setOverwriteMode
(overwrite)
def
setPlaceholderText
(placeholderText)
def
setReadOnly
(ro)
def
setTabChangesFocus
(b)
def
setTabStopDistance
(distance)
def
setTabStopWidth
(width)
def
setTextCursor
(cursor)
def
setTextInteractionFlags
(flags)
def
setUndoRedoEnabled
(enable)
def
setWordWrapMode
(policy)
def
tabChangesFocus
()
def
tabStopDistance
()
def
tabStopWidth
()
def
textBackgroundColor
()
def
textColor
()
def
textCursor
()
def
textInteractionFlags
()
def
toHtml
()
def
toMarkdown
([features=QTextDocument.MarkdownDialectGitHub])
def
toPlainText
()
def
wordWrapMode
()
def
zoomInF
(range)
def
canInsertFromMimeData
(source)
def
createMimeDataFromSelection
()
def
doSetTextCursor
(cursor)
def
insertFromMimeData
(source)
def
loadResource
(type, name)
def
append
(text)
def
clear
()
def
copy
()
def
cut
()
def
insertHtml
(text)
def
insertPlainText
(text)
def
paste
()
def
redo
()
def
scrollToAnchor
(name)
def
selectAll
()
def
setAlignment
(a)
def
setCurrentFont
(f)
def
setFontFamily
(fontFamily)
def
setFontItalic
(b)
def
setFontPointSize
(s)
def
setFontUnderline
(b)
def
setFontWeight
(w)
def
setHtml
(text)
def
setMarkdown
(markdown)
def
setPlainText
(text)
def
setText
(text)
def
setTextBackgroundColor
(c)
def
setTextColor
(c)
def
undo
()
def
zoomIn
([range=1])
def
zoomOut
([range=1])
def
copyAvailable
(b)
def
currentCharFormatChanged
(format)
def
cursorPositionChanged
()
def
redoAvailable
(b)
def
selectionChanged
()
def
textChanged
()
def
undoAvailable
(b)
QTextEditis 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.
QTextEditworks 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.
QTextEditcan 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
QTextEditisIBeamCursor默认情况下。它可以被改变透过viewport()‘s cursor property.
QTextEditcan display a large HTML subset, including tables and images.可以设置或替换文本使用
setHtml()which deletes any existing text and replaces it with the text passed in thesetHtml()call. If you callsetHtml()with legacy HTML, and then calltoHtml(), the text that is returned may have different markup, but will render the same. The entire text can be deleted withclear().还可以设置或替换文本使用
setMarkdown(), and the same caveats apply: if you then calltoMarkdown(), 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 thatsetHtml()has; buttoMarkdown()only writes “pure” Markdown, without any embedded HTML.可以插入文字本身使用
QTextCursor类或使用方便函数insertHtml(),insertPlainText(),append()orpaste().QTextCursor还能够把复杂对象 (像:表格或列表) 插入文档,且它能够处理创建选择并将改变应用到选中文本。默认情况下,文本编辑在空白处自动换行以拟合在文本编辑 Widget 中。
setLineWrapMode()function is used to specify the kind of line wrap you want, orNoWrapif you don’t want any wrapping. CallsetLineWrapMode()to set a fixed pixel widthFixedPixelWidth,或字符列 (如:80 列)FixedColumnWidth按指定像素或列数采用setLineWrapColumnOrWidth(). If you use word wrap to the widget’s widthWidgetWidth,可以指定是在空白处断开还是在任何地方断开采用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 useQTextDocument‘s maximumBlockCount property for that.
当
QTextEditis 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 文档才工作,若字体尺寸未设为固定大小。
All the information about using
QTextEditas a display widget also applies here.The current char format’s attributes are set with
setFontItalic(),setFontWeight(),setFontUnderline(),setFontFamily(),setFontPointSize(),setTextColor()andsetCurrentFont(). The current paragraph’s alignment is set withsetAlignment().文本选择的处理通过
QTextCursor类,提供创建选择、检索文本内容或删除选定的功能。可以检索对应用户可见光标的对象使用textCursor()method. If you want to set a selection inQTextEditjust create one on aQTextCursor对象然后使该光标成为可见光标使用setTextCursor(). The selection can be copied to the clipboard withcopy(), or cut to the clipboard withcut(). The entire text can be selected usingselectAll().当光标被移动且底层格式化属性改变时,
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 ofsetText()or through the editor itself).
QTextEditholds aQTextDocument对象,可以被检索使用document()method. You can also set your own document object usingsetDocument().
QTextDocument提供isModified()函数,返回 true 若文本在加载或采用 false 作为自变量最后调用 setModified 后被修改。此外,它提供撤消和重做方法。
QTextEditalso supports custom drag and drop behavior. By default,QTextEditwill insert plain text, HTML and rich text when the user drops data of these MIME types onto a document. ReimplementcanInsertFromMimeData()andinsertFromMimeData()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 将选择右侧单词,等等。
QTextEdit
(
[
parent=None
]
)
¶
QTextEdit(text[, parent=None])
- param parent
- 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
返回当前段落的对齐方式。
另请参阅
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
(
)
¶
删除文本编辑中的所有文本。
注意事项:
撤消/重做历史也被清零。
currentCharFormat()
is reset, unless
textCursor()
is already at the beginning of the document.
另请参阅
PySide2.QtWidgets.QTextEdit.
copy
(
)
¶
把任何选中文本拷贝到剪贴板。
另请参阅
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
(
)
¶
此函数创建要展示的标准上下文菜单,当用户采用鼠标右键点击文本编辑时。它被调用从默认
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
此函数创建要展示的标准上下文菜单,当用户采用鼠标右键点击文本编辑时。它被调用从默认
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
另请参阅
PySide2.QtWidgets.QTextEdit.
cut
(
)
¶
把选中文本拷贝到剪贴板,并将其从文本编辑中删除。
若没有选中文本,什么都不发生。
PySide2.QtWidgets.QTextEdit.
doSetTextCursor
(
cursor
)
¶
cursor
–
QTextCursor
This provides a hook for subclasses to intercept cursor changes.
PySide2.QtWidgets.QTextEdit.
document
(
)
¶
QTextDocument
另请参阅
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。
另请参阅
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
(
)
¶
另请参阅
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()
函数。
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.
另请参阅
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
另请参阅
PySide2.QtWidgets.QTextEdit.
setAlignment
(
a
)
¶
a
–
Alignment
把当前段落的对齐方式设为
a
。有效对齐方式是
AlignLeft
,
AlignRight
,
AlignJustify
and
AlignCenter
(水平居中)。
另请参阅
PySide2.QtWidgets.QTextEdit.
setAutoFormatting
(
features
)
¶
features
–
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
另请参阅
PySide2.QtWidgets.QTextEdit.
setDocument
(
document
)
¶
document
–
QTextDocument
另请参阅
PySide2.QtWidgets.QTextEdit.
setDocumentTitle
(
title
)
¶
title – unicode
另请参阅
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.
另请参阅
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.
另请参阅
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
另请参阅
PySide2.QtWidgets.QTextEdit.
setMarkdown
(
markdown
)
¶
markdown – unicode
PySide2.QtWidgets.QTextEdit.
setOverwriteMode
(
overwrite
)
¶
overwrite
–
bool
另请参阅
PySide2.QtWidgets.QTextEdit.
setPlaceholderText
(
placeholderText
)
¶
placeholderText – unicode
另请参阅
PySide2.QtWidgets.QTextEdit.
setPlainText
(
text
)
¶
text – unicode
把文本编辑的文本更改为字符串
text
。移除任何以前文本。
注意事项:
text
被解释为纯文本。
撤消/重做历史也被清零。
currentCharFormat()
is reset, unless
textCursor()
is already at the beginning of the document.
另请参阅
PySide2.QtWidgets.QTextEdit.
setReadOnly
(
ro
)
¶
ro
–
bool
另请参阅
PySide2.QtWidgets.QTextEdit.
setTabChangesFocus
(
b
)
¶
b
–
bool
另请参阅
PySide2.QtWidgets.QTextEdit.
setTabStopDistance
(
distance
)
¶
distance
–
qreal
另请参阅
PySide2.QtWidgets.QTextEdit.
setTabStopWidth
(
width
)
¶
width
–
int
注意
此函数被弃用。
另请参阅
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
.
另请参阅
PySide2.QtWidgets.QTextEdit.
setTextCursor
(
cursor
)
¶
cursor
–
QTextCursor
设置可见
cursor
.
另请参阅
PySide2.QtWidgets.QTextEdit.
setTextInteractionFlags
(
flags
)
¶
flags
–
TextInteractionFlags
PySide2.QtWidgets.QTextEdit.
setUndoRedoEnabled
(
enable
)
¶
enable
–
bool
另请参阅
PySide2.QtWidgets.QTextEdit.
setWordWrapMode
(
policy
)
¶
policy
–
WrapMode
另请参阅
PySide2.QtWidgets.QTextEdit.
tabChangesFocus
(
)
¶
bool
另请参阅
PySide2.QtWidgets.QTextEdit.
tabStopDistance
(
)
¶
qreal
另请参阅
PySide2.QtWidgets.QTextEdit.
tabStopWidth
(
)
¶
int
注意
此函数被弃用。
另请参阅
PySide2.QtWidgets.QTextEdit.
textBackgroundColor
(
)
¶
QColor
返回当前格式的文本背景颜色。
PySide2.QtWidgets.QTextEdit.
textChanged
(
)
¶
PySide2.QtWidgets.QTextEdit.
textColor
(
)
¶
QColor
返回当前格式的文本颜色。
另请参阅
PySide2.QtWidgets.QTextEdit.
textCursor
(
)
¶
QTextCursor
返回副本为
QTextCursor
表示当前可见光标。注意:改变返回光标不影响
QTextEdit
‘s cursor; use
setTextCursor()
to update the visible cursor.
另请参阅
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
把文本编辑的文本作为纯文本返回。
另请参阅
PySide2.QtWidgets.QTextEdit.
undoAvailable
(
b
)
¶
b
–
bool
PySide2.QtWidgets.QTextEdit.
wordWrapMode
(
)
¶
WrapMode
另请参阅
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.
另请参阅
PySide2.QtWidgets.QTextEdit.
zoomInF
(
range
)
¶
range
–
float