QLineEdit(QWidget) | |||
描述 | 是一个单行文本编辑器,自带撤消,重做,剪切,粘贴,拖放 | ||
创建 | 控件的创建 | QLineEdit(str, parent: QWidget = None) | |
文本的设置和获取 | 设置内容文本 | setText(str) | |
在光标处插入文本 | insert(newText) | ||
获取真实内容文本 | text() | ||
获取用户能看到的内容文本 | displayText() | ||
输出模式 | 设置模式 | setEchoMode(QLineEdit.EchoMode) | |
获取模式 | echoMode() -> QLineEdit.EchoMode | ||
占位提示 | 描述 | 在用户输入文本内容之前, 给用户的提示语句 | |
设置 | setPlaceholderText(notice_str) | ||
获取 | placeholderText() | ||
清空按钮 | 设置 | setClearButtonEnabled(bool) | |
判断 | isClearButtonEnabled() -> bool | ||
添加行为 | addAction(QAction, QLineEdit.ActionPosition) | ||
addAction(QIcon, QLineEdit.ActionPosition) -> QAction | |||
自动补全 | 设置完成器 | setCompleter(QCompleter) | 设置候补项 |
completer() -> QCompleter | 以字符串列表的形式 | ||
输入限制 | 限制内容长度 | setMaxLength(int) | |
获取输入长度 | maxLength() | ||
只读限制 | setReadOnly(bool) | ||
是否只读 | isReadOnly() | ||
设置验证器 | setValidator(QValidator) | 子项速查 | |
掩码验证 | setInputMask(mask_str) | 子项速查掩码字符表 | |
判定输入文本是否通过验证 | hasAcceptableInput() | ||
是否被编辑 | 标识文本内容是否被修改 | isModified()/setModified(bool) | |
光标控制 | 向后(左)移动steps个字符 | cursorBackward(bool mark,int steps = 1) | True带选中效果 False不带选中效果 |
向前(右)移动steps个字符 | cursorForward(bool mark,int steps = 1) | ||
向后(左)移动一个单词长度 | cursorWordBackward(bool mark) | ||
向前(右)移动一个单词长度 | cursorWordForward(bool mark) | ||
移动到行首 | home(bool) | ||
移动到行尾 | end(bool) | ||
设置光标位置 | setCursorPosition(int) | ||
获取光标位置 | cursorPosition() | ||
获取指定坐标位置对应文本光标位置 | cursorPositionAt(const QPoint& pos) | ||
文本边距设置 | 获取文本内容边距 | getTextMargins() | |
设置文本内容边距 | setTextMargins(int left,int top,int right,int bottom) | ||
对齐方式 | 设置对齐方式 | setAlignment(Qt.Alignment) | 子项速查 |
获取对齐方式 | alignment() -> Qt.Alignment | ||
常用编辑功能 | 退格 | backspace() | |
删除 | del_() | ||
清空 | clear() | ||
复制 | copy() | ||
剪切 | cut() | ||
粘贴 | paste() | ||
撤消 | isUndoAvailable()/undo() | ||
重做 | isRedoAvailable()/redo() | ||
拖放 | setDragEnabled(bool) | 设置选中文本后是否可以拖拽 | |
文本选中 | setSelection(start_pos, length) | 选中指定区间的文本 | |
selectAll() | 选中所有文本 | ||
deselect() | 取消选中已选择文本 | ||
hasSelectedText() | 是否有选中文本 | ||
selectedText() -> str | 获取选中的文本 | ||
selectionStart() -> int | 选中的开始位置 | ||
selectionEnd() -> int | 选中的结束位置 | ||
selectionLength() -> int | 选中的长度 | ||
信号 | 文本编辑时发射的信号 | textEdited( text) | 常用 |
文本框文本发生改变时发出的信号 | textChanged(text) | ||
按下回车键时发出的信号 | returnPressed() | ||
结束编辑时发出的信号 | editingFinished() | ||
光标位置发生改变时发出的信号 | cursorPositionChanged(int oldPos,int newPos) | ||
选中的文本发生改变时发出的信号 | selectionChanged() |
QLineEdit
最新推荐文章于 2024-07-01 10:47:17 发布