def
addAction
(action, position)
def
addAction
(icon, position)
def
alignment
()
def
backspace
()
def
completer
()
def
createStandardContextMenu
()
def
cursorBackward
(mark[, steps=1])
def
cursorForward
(mark[, steps=1])
def
cursorMoveStyle
()
def
cursorPosition
()
def
cursorPositionAt
(pos)
def
cursorRect
()
def
cursorWordBackward
(mark)
def
cursorWordForward
(mark)
def
del_
()
def
deselect
()
def
displayText
()
def
dragEnabled
()
def
echoMode
()
def
end
(mark)
def
getTextMargins
()
def
hasAcceptableInput
()
def
hasFrame
()
def
hasSelectedText
()
def
home
(mark)
def
initStyleOption
(option)
def
inputMask
()
def
inputMethodQuery
(property, argument)
def
insert
(arg__1)
def
isClearButtonEnabled
()
def
isModified
()
def
isReadOnly
()
def
isRedoAvailable
()
def
isUndoAvailable
()
def
maxLength
()
def
placeholderText
()
def
selectedText
()
def
selectionEnd
()
def
selectionLength
()
def
selectionStart
()
def
setAlignment
(flag)
def
setClearButtonEnabled
(enable)
def
setCompleter
(completer)
def
setCursorMoveStyle
(style)
def
setCursorPosition
(arg__1)
def
setDragEnabled
(b)
def
setEchoMode
(arg__1)
def
setFrame
(arg__1)
def
setInputMask
(inputMask)
def
setMaxLength
(arg__1)
def
setModified
(arg__1)
def
setPlaceholderText
(arg__1)
def
setReadOnly
(arg__1)
def
setSelection
(arg__1, arg__2)
def
setTextMargins
(left, top, right, bottom)
def
setTextMargins
(margins)
def
setValidator
(arg__1)
def
text
()
def
textMargins
()
def
validator
()
def
cursorPositionChanged
(arg__1, arg__2)
def
editingFinished
()
def
inputRejected
()
def
returnPressed
()
def
selectionChanged
()
def
textChanged
(arg__1)
def
textEdited
(arg__1)
![]()
行编辑允许用户键入和编辑单行纯文本,采用有用编辑功能的集合,包括:撤消/重做、剪切/粘贴及拖放 (见
setDragEnabled()).通过改变
echoMode()of a line edit, it can also be used as a “write-only” field, for inputs such as passwords.可以把文本长度约束到
maxLength(). The text can be arbitrarily constrained using avalidator()or aninputMask(), or both. When switching between a validator and an input mask on the same line edit, it is best to clear the validator or input mask to prevent undefined behavior.相关类
QTextEdit允许多行,编辑富文本。可以改变文本采用
setText()orinsert(). The text is retrieved withtext(); the displayed text (which may be different, seeEchoMode) 的检索采用displayText(). Text can be selected withsetSelection()orselectAll(), and the selection can becut(),copy()ied andpaste()d. The text can be aligned withsetAlignment().当文本改变时
textChanged()signal is emitted; when the text changes other than by callingsetText()thetextEdited()signal is emitted; when the cursor is moved thecursorPositionChanged()signal is emitted; and when the Return or Enter key is pressed thereturnPressed()信号被发射。当编辑完成时,由于行编辑失去聚焦或按下 Return/Enter 键
editingFinished()信号被发射。注意:若行编辑有设置验证器,
returnPressed()/editingFinished()signals will only be emitted if the validator returnsAcceptable.默认情况下,QLineEdit 拥有由平台风格指南指定的框架;可以关闭它通过调用
setFrame(false).The default key bindings are described below. The line edit also provides a context menu (usually invoked by a right mouse click) that presents some of these editing options. .. _desc:
Keypress
Action
Left Arrow
左移光标一字符。
Shift+Left Arrow
左移并选择文本一字符。
Right Arrow
右移光标一字符。
Shift+Right Arrow
右移并选择文本一字符。
首页
把光标移到行开头。
End
把光标移到行尾。
Backspace
删除光标左侧字符。
Ctrl+Backspace
删除光标左侧的单词。
Delete
删除光标右侧字符。
Ctrl+Delete
删除光标右侧的单词。
Ctrl+A
选择所有。
Ctrl+C
把选中文本拷贝到剪贴板。
Ctrl+Insert
把选中文本拷贝到剪贴板。
Ctrl+K
删除到行尾。
Ctrl+V
将剪贴板文本粘贴到行编辑。
Shift+Insert
将剪贴板文本粘贴到行编辑。
Ctrl+X
删除选中文本并把它拷贝到剪贴板。
Shift+Delete
删除选中文本并把它拷贝到剪贴板。
Ctrl+Z
撤消上一操作。
Ctrl+Y
重做上一撤消操作。
表示有效字符的任何其它键序列,将导致该字符被插入行编辑。
QLineEdit
(
[
parent=None
]
)
¶
QLineEdit(arg__1[, parent=None])
- param parent
- param arg__1
unicode
构造行编辑不采用文本。
最大文本长度被设为 32767 个字符。
parent
自变量被发送给
QWidget
构造函数。
另请参阅
构造行编辑包含文本
contents
.
光标位置被设为行尾,且最大文本长度被设为 32767 个字符。
parent
和自变量被发送给
QWidget
构造函数。
另请参阅
PySide2.QtWidgets.QLineEdit.
ActionPosition
¶
此枚举类型描述行编辑应该如何显示要被添加的动作 Widget。
|
常量 |
描述 |
|---|---|
|
QLineEdit.LeadingPosition |
Widget 显示在文本左侧当使用布局方向
|
|
QLineEdit.TrailingPosition |
Widget 显示在文本右侧当使用布局方向
|
PySide2.QtWidgets.QLineEdit.
EchoMode
¶
此枚举类型描述行编辑应如何显示其内容。
|
常量 |
描述 |
|---|---|
|
QLineEdit.Normal |
显示字符如键入它们时。这是默认值。 |
|
QLineEdit.NoEcho |
不显示任何东西。这可能适用于口令 (即使口令长度也应保密)。 |
|
QLineEdit.Password |
显示从属平台的口令掩码字符,而不是实际键入字符。 |
|
QLineEdit.PasswordEchoOnEdit |
显示字符如键入它们当编辑时,否则显示字符如采用
|
另请参阅
PySide2.QtWidgets.QLineEdit.
addAction
(
icon
,
position
)
¶
icon
–
QIcon
position
–
ActionPosition
PySide2.QtWidgets.QLineEdit.
addAction
(
action
,
position
)
¶
action
–
QAction
position
–
ActionPosition
添加
action
到动作列表在
position
.
PySide2.QtWidgets.QLineEdit.
alignment
(
)
¶
Alignment
另请参阅
PySide2.QtWidgets.QLineEdit.
backspace
(
)
¶
若未选择文本,删除文本光标左侧字符并左移光标一位置。若有选择任何文本,光标将移动到选定文本的开头并删除所选文本。
另请参阅
del()
PySide2.QtWidgets.QLineEdit.
clear
(
)
¶
清零行编辑的内容。
PySide2.QtWidgets.QLineEdit.
completer
(
)
¶
返回当前
QCompleter
,其提供补全。
另请参阅
PySide2.QtWidgets.QLineEdit.
copy
(
)
¶
把选中文本拷贝到剪贴板 (若有的话),且若
echoMode()
is
Normal
.
PySide2.QtWidgets.QLineEdit.
createStandardContextMenu
(
)
¶
此函数创建要展示的标准上下文菜单,当用户采用鼠标右键点击行编辑时。它被调用从默认
contextMenuEvent()
handler. The popup menu’s ownership is transferred to the caller.
PySide2.QtWidgets.QLineEdit.
cursorBackward
(
mark
[
,
steps=1
]
)
¶
mark
–
bool
steps
–
int
后移光标
steps
字符。若
mark
为 true,每个移过字符会被添加到选定;若
mark
为 False,清零选定。
另请参阅
PySide2.QtWidgets.QLineEdit.
cursorForward
(
mark
[
,
steps=1
]
)
¶
mark
–
bool
steps
–
int
前移光标
steps
字符。若
mark
为 true,每个移过字符会被添加到选定;若
mark
为 False,清零选定。
另请参阅
PySide2.QtWidgets.QLineEdit.
cursorMoveStyle
(
)
¶
CursorMoveStyle
另请参阅
PySide2.QtWidgets.QLineEdit.
cursorPosition
(
)
¶
int
另请参阅
PySide2.QtWidgets.QLineEdit.
cursorPositionAt
(
pos
)
¶
pos
–
QPoint
int
返回光标位置在点
pos
.
PySide2.QtWidgets.QLineEdit.
cursorPositionChanged
(
arg__1
,
arg__2
)
¶
arg__1
–
int
arg__2
–
int
PySide2.QtWidgets.QLineEdit.
cursorRect
(
)
¶
QRect
返回包括行编辑光标的矩形。
PySide2.QtWidgets.QLineEdit.
cursorWordBackward
(
mark
)
¶
mark
–
bool
将光标后移一单词。若
mark
为 true,单词还被选中。
另请参阅
PySide2.QtWidgets.QLineEdit.
cursorWordForward
(
mark
)
¶
mark
–
bool
将光标前移一单词。若
mark
为 true,单词还被选中。
另请参阅
PySide2.QtWidgets.QLineEdit.
cut
(
)
¶
把选中文本拷贝到剪贴板且删除它 (若有的话),且若
echoMode()
is
Normal
.
If the current validator disallows deleting the selected text, will copy without deleting.
另请参阅
PySide2.QtWidgets.QLineEdit.
del_
(
)
¶
若未选择文本,删除文本光标右侧字符。若有选择任何文本,光标将移动到选定文本的开头并删除所选文本。
另请参阅
PySide2.QtWidgets.QLineEdit.
deselect
(
)
¶
取消任何选中文本的选择。
PySide2.QtWidgets.QLineEdit.
displayText
(
)
¶
unicode
PySide2.QtWidgets.QLineEdit.
dragEnabled
(
)
¶
bool
另请参阅
PySide2.QtWidgets.QLineEdit.
echoMode
(
)
¶
另请参阅
PySide2.QtWidgets.QLineEdit.
editingFinished
(
)
¶
PySide2.QtWidgets.QLineEdit.
end
(
mark
)
¶
mark
–
bool
将光标移至行末尾,除非光标已移到那里。若
mark
为 true,选择文本到最后位置;否则,取消选择任何文本的选定若光标被移动。
另请参阅
PySide2.QtWidgets.QLineEdit.
getTextMargins
(
)
¶
注意
此函数被弃用。
Returns the widget’s text margins for
left
,
top
,
right
,和
bottom
.
另请参阅
PySide2.QtWidgets.QLineEdit.
hasAcceptableInput
(
)
¶
bool
PySide2.QtWidgets.QLineEdit.
hasFrame
(
)
¶
bool
PySide2.QtWidgets.QLineEdit.
hasSelectedText
(
)
¶
bool
PySide2.QtWidgets.QLineEdit.
home
(
mark
)
¶
mark
–
bool
将光标移至行开头,除非光标已移到那里。若
mark
为 true,选择文本到第一位置;否则,取消选择任何文本的选定若光标被移动。
另请参阅
PySide2.QtWidgets.QLineEdit.
initStyleOption
(
option
)
¶
option
–
QStyleOptionFrame
初始化
option
采用值来自此
QLineEdit
。此方法对子类是有用的,当需要
QStyleOptionFrame
, but don’t want to fill in all the information themselves.
另请参阅
PySide2.QtWidgets.QLineEdit.
inputMask
(
)
¶
unicode
另请参阅
PySide2.QtWidgets.QLineEdit.
inputMethodQuery
(
特性
,
argument
)
¶
特性
–
InputMethodQuery
argument – object
object
PySide2.QtWidgets.QLineEdit.
inputRejected
(
)
¶
PySide2.QtWidgets.QLineEdit.
insert
(
arg__1
)
¶
arg__1 – unicode
删除任何选中文本,插入
newText
,并验证结果。若有效,则将其设为行编辑的新内容。
PySide2.QtWidgets.QLineEdit.
isClearButtonEnabled
(
)
¶
bool
PySide2.QtWidgets.QLineEdit.
isModified
(
)
¶
bool
PySide2.QtWidgets.QLineEdit.
isReadOnly
(
)
¶
bool
PySide2.QtWidgets.QLineEdit.
isRedoAvailable
(
)
¶
bool
PySide2.QtWidgets.QLineEdit.
isUndoAvailable
(
)
¶
bool
PySide2.QtWidgets.QLineEdit.
maxLength
(
)
¶
int
另请参阅
PySide2.QtWidgets.QLineEdit.
paste
(
)
¶
Inserts the clipboard’s text at the cursor position, deleting any selected text, providing the line edit is not
只读
.
若最终结果无效,对当前
validator
,什么都不发生。
PySide2.QtWidgets.QLineEdit.
placeholderText
(
)
¶
unicode
另请参阅
PySide2.QtWidgets.QLineEdit.
redo
(
)
¶
重做上一操作,若重做
available
.
PySide2.QtWidgets.QLineEdit.
returnPressed
(
)
¶
PySide2.QtWidgets.QLineEdit.
selectAll
(
)
¶
选择所有文本 (即:突显文本) 并将光标移至末尾。这很有用当插入默认值时,因为若用户在点击 Widget 之前键入,则选中文本会被删除。
另请参阅
PySide2.QtWidgets.QLineEdit.
selectedText
(
)
¶
unicode
PySide2.QtWidgets.QLineEdit.
selectionChanged
(
)
¶
PySide2.QtWidgets.QLineEdit.
selectionEnd
(
)
¶
int
返回行编辑选定之后的直接字符索引,或-1 若未选中文本。
PySide2.QtWidgets.QLineEdit.
selectionLength
(
)
¶
int
返回选定长度。
PySide2.QtWidgets.QLineEdit.
selectionStart
(
)
¶
int
返回行编辑第一选中字符的索引,或 -1 若没有文本被选中。
PySide2.QtWidgets.QLineEdit.
setAlignment
(
flag
)
¶
flag
–
Alignment
另请参阅
PySide2.QtWidgets.QLineEdit.
setClearButtonEnabled
(
enable
)
¶
enable
–
bool
PySide2.QtWidgets.QLineEdit.
setCompleter
(
completer
)
¶
completer
–
QCompleter
将为此行编辑提供自动补全的补全器设为
c
。补全模式的设置使用
setCompletionMode()
.
要使用
QCompleter
采用
QValidator
or
inputMask
,需要确保模型被提供给
QCompleter
包含有效条目。可以使用
QSortFilterProxyModel
以确保
QCompleter
‘s model contains only valid entries.
若
c
== 0, removes the current completer, effectively disabling auto completion.
另请参阅
PySide2.QtWidgets.QLineEdit.
setCursorMoveStyle
(
style
)
¶
style
–
CursorMoveStyle
另请参阅
PySide2.QtWidgets.QLineEdit.
setCursorPosition
(
arg__1
)
¶
arg__1
–
int
另请参阅
PySide2.QtWidgets.QLineEdit.
setDragEnabled
(
b
)
¶
b
–
bool
另请参阅
PySide2.QtWidgets.QLineEdit.
setFrame
(
arg__1
)
¶
arg__1
–
bool
另请参阅
PySide2.QtWidgets.QLineEdit.
setInputMask
(
inputMask
)
¶
inputMask – unicode
另请参阅
PySide2.QtWidgets.QLineEdit.
setMaxLength
(
arg__1
)
¶
arg__1
–
int
另请参阅
PySide2.QtWidgets.QLineEdit.
setModified
(
arg__1
)
¶
arg__1
–
bool
另请参阅
PySide2.QtWidgets.QLineEdit.
setPlaceholderText
(
arg__1
)
¶
arg__1 – unicode
另请参阅
PySide2.QtWidgets.QLineEdit.
setReadOnly
(
arg__1
)
¶
arg__1
–
bool
另请参阅
PySide2.QtWidgets.QLineEdit.
setSelection
(
arg__1
,
arg__2
)
¶
arg__1
–
int
arg__2
–
int
选择文本从位置
start
和对于
length
个字符。负长度是允许的。
PySide2.QtWidgets.QLineEdit.
setTextMargins
(
margins
)
¶
margins
–
QMargins
设置
margins
围绕文本在框架内。
另请参阅
textMargins()
.
PySide2.QtWidgets.QLineEdit.
setTextMargins
(
left
,
top
,
right
,
bottom
)
¶
left
–
int
top
–
int
right
–
int
bottom
–
int
将框架围绕文本的边距尺寸设为
left
,
top
,
right
,和
bottom
.
另请参阅
textMargins()
.
另请参阅
PySide2.QtWidgets.QLineEdit.
setValidator
(
arg__1
)
¶
arg__1
–
QValidator
把行编辑值的验证器设为
v
.
The line edit’s
returnPressed()
and
editingFinished()
signals will only be emitted if
v
validates the line edit’s content as
Acceptable
。用户可以将内容更改为任何
中间体
值在编辑期间,但将阻止将文本编辑为值
v
验证按
Invalid
.
这允许约束当编辑完成时最终要键入的文本,同时使用户有足够自由从一种有效状态到另一种有效状态编辑文本。
若
v
== 0, removes the current input validator. The initial setting is to have no input validator (i.e. any input is accepted up to
maxLength()
).
PySide2.QtWidgets.QLineEdit.
textChanged
(
arg__1
)
¶
arg__1 – unicode
PySide2.QtWidgets.QLineEdit.
textEdited
(
arg__1
)
¶
arg__1 – unicode
PySide2.QtWidgets.QLineEdit.
textMargins
(
)
¶
QMargins
Returns the widget’s text margins.
另请参阅
PySide2.QtWidgets.QLineEdit.
undo
(
)
¶
撤消上一操作,若撤消
available
。取消当前任何选定,并将选择起始更新成当前光标位置。
PySide2.QtWidgets.QLineEdit.
validator
(
)
¶
QValidator
返回指向当前输入验证器的指针,或
None
若没有设置验证器。
另请参阅