QLineEdit#
The QLineEdit
widget is a one-line text editor. More…
Synopsis#
Properties#
acceptableInput
- Whether the input satisfies the inputMask and the validatoralignment
- Of the line editclearButtonEnabled
- Whether the line edit displays a clear button when it is not emptycursorMoveStyle
- Movement style of the cursor in this line editcursorPosition
- Current cursor position for this line editdisplayText
- Displayed textdragEnabled
- Whether the line edit starts a drag if the user presses and moves the mouse on some selected textechoMode
- Line edit’s echo modeframe
- Whether the line edit draws itself with a framehasSelectedText
- Whether there is any text selectedinputMask
- Validation input maskmaxLength
- Maximum permitted length of the textmodified
- Whether the line edit’s contents has been modified by the userplaceholderText
- Line edit’s placeholder textreadOnly
- Whether the line edit is read-onlyredoAvailable
- Whether redo is availableselectedText
- Selected texttext
- Line edit’s textundoAvailable
- Whether undo is available
Functions#
def
addAction
(icon, position)def
addAction
(action, 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
hasAcceptableInput
()def
hasFrame
()def
hasSelectedText
()def
home
(mark)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
(margins)def
setTextMargins
(left, top, right, bottom)def
setValidator
(arg__1)def
text
()def
textMargins
()def
validator
()
Virtual functions#
def
initStyleOption
(option)
Slots#
Signals#
def
cursorPositionChanged
(arg__1, arg__2)def
editingFinished
()def
inputRejected
()def
returnPressed
()def
selectionChanged
()def
textChanged
(arg__1)def
textEdited
(arg__1)
Note
This documentation may contain snippets that were automatically translated from C++ to Python. We always welcome contributions to the snippet translation. If you see an issue with the translation, you can also let us know by creating a ticket on https:/bugreports.qt.io/projects/PYSIDE
Detailed Description#
A line edit allows users to enter and edit a single line of plain text with useful editing functions, including undo and redo, cut and paste, and drag and drop.
By changing the echoMode()
of a line edit, it can also be used as a write-only field for inputs such as passwords.
QTextEdit
is a related class that allows multi-line, rich text editing.
Constraining Text#
Use maxLength
to define the maximum permitted length of a text. You can use a inputMask
and setValidator()
to further constrain the text content.
Editing Text#
You can change the text with setText()
or insert()
. Use text()
to retrieve the text and displayText()
to retrieve the displayed text (which may be different, see EchoMode
). You can select the text with setSelection()
or selectAll()
, and you can cut()
, copy()
, and paste()
the selection. To align the text, use setAlignment()
.
When the text changes, the textChanged()
signal is emitted. When the text changes in some other way than by calling setText()
, the textEdited()
signal is emitted. When the cursor is moved, the cursorPositionChanged()
signal is emitted. And when the Return or Enter key is selected, the returnPressed()
signal is emitted.
When text editing is finished, either because the line edit lost focus or Return/Enter was selected, the editingFinished()
signal is emitted.
If the line edit focus is lost without any text changes, the editingFinished()
signal won’t be emitted.
If there is a validator set on the line edit, the returnPressed()
/ editingFinished()
signals will only be emitted if the validator returns QValidator::Acceptable.
For more information on the many ways that QLineEdit
can be used, see Line Edits Example , which also provides a selection of line edit examples that show the effects of various properties and validators on the input and output supplied by the user.
Setting a Frame#
By default, QLineEdits have a frame as specified in the platform style guides. You can turn the frame off by calling setFrame
(false).
Default Key Bindings#
The table below describes the default key bindings.
Note
The line edit also provides a context menu (usually invoked by a right-click) that presents some of the editing options listed below.
Keystroke |
Action |
---|---|
Left Arrow |
Moves the cursor one character to the left. |
Shift+Left Arrow |
Moves and selects text one character to the left. |
Right Arrow |
Moves the cursor one character to the right. |
Shift+Right Arrow |
Moves and selects text one character to the right. |
Home |
Moves the cursor to the beginning of the line. |
End |
Moves the cursor to the end of the line. |
Backspace |
Deletes the character to the left of the cursor. |
Ctrl+Backspace |
Deletes the word to the left of the cursor. |
Delete |
Deletes the character to the right of the cursor. |
Ctrl+Delete |
Deletes the word to the right of the cursor. |
Ctrl+A |
Selects all. |
Ctrl+C |
Copies the selected text to the clipboard. |
Ctrl+Insert |
Copies the selected text to the clipboard. |
Ctrl+K |
Deletes to the end of the line. |
Ctrl+V |
Pastes the clipboard text into line edit. |
Shift+Insert |
Pastes the clipboard text into line edit. |
Ctrl+X |
Deletes the selected text and copies it to the clipboard. |
Shift+Delete |
Deletes the selected text and copies it to the clipboard. |
Ctrl+Z |
Undoes the last operation. |
Ctrl+Y |
Redoes the last undone operation. |
Any other keystroke that represents a valid character, will cause the character to be inserted into the line edit.
See also
- class PySide6.QtWidgets.QLineEdit([parent=None])#
PySide6.QtWidgets.QLineEdit(arg__1[, parent=None])
- Parameters:
arg__1 – str
parent –
PySide6.QtWidgets.QWidget
Constructs a line edit with no text.
The maximum text length is set to 32767 characters.
The parent
argument is sent to the QWidget
constructor.
See also
Constructs a line edit containing the text contents
as a child of parent
.
The cursor position is set to the end of the line and the maximum text length to 32767 characters.
See also
Note
Properties can be used directly when from __feature__ import true_property
is used or via accessor functions otherwise.
- property PᅟySide6.QtWidgets.QLineEdit.acceptableInput: bool#
This property holds Whether the input satisfies the inputMask
and the validator..
By default, this property is true
.
See also
- Access functions:
- property PᅟySide6.QtWidgets.QLineEdit.alignment: Combination of Qt.AlignmentFlag#
This property holds The alignment of the line edit..
Both horizontal and vertical alignment is allowed here, Qt::AlignJustify will map to Qt::AlignLeft.
By default, this property contains a combination of Qt::AlignLeft and Qt::AlignVCenter.
See also
Alignment
- Access functions:
alignment
()setAlignment
(flag)
- property PᅟySide6.QtWidgets.QLineEdit.clearButtonEnabled: bool#
This property holds Whether the line edit displays a clear button when it is not empty..
If enabled, the line edit displays a trailing clear button when it contains some text. Otherwise, the line edit does not show a clear button (the default).
See also
- Access functions:
setClearButtonEnabled
(enable)
- property PᅟySide6.QtWidgets.QLineEdit.cursorMoveStyle: CursorMoveStyle#
This property holds The movement style of the cursor in this line edit..
When this property is set to Qt::VisualMoveStyle, the line edit will use a visual movement style. Using the left arrow key will always cause the cursor to move left, regardless of the text’s writing direction. The same behavior applies to the right arrow key.
When the property is set to Qt::LogicalMoveStyle (the default), within a left-to-right (LTR) text block, using the left arrow key will increase the cursor position, whereas using the right arrow key will decrease the cursor position. If the text block is right-to-left (RTL), the opposite behavior applies.
- Access functions:
setCursorMoveStyle
(style)
- property PᅟySide6.QtWidgets.QLineEdit.cursorPosition: int#
This property holds The current cursor position for this line edit..
Setting the cursor position causes a repaint when appropriate.
By default, this property contains a value of 0.
- Access functions:
setCursorPosition
(arg__1)
- property PᅟySide6.QtWidgets.QLineEdit.displayText: str#
This property holds The displayed text..
If echoMode
is Normal
, this returns the same as text()
. If EchoMode
is Password
or PasswordEchoOnEdit
, it returns a string of platform-dependent password mask characters (e.g. “******”). If EchoMode
is NoEcho
, it returns an empty string.
By default, this property contains an empty string.
See also
setEchoMode()
text()
EchoMode
- Access functions:
displayText
()
- property PᅟySide6.QtWidgets.QLineEdit.dragEnabled: bool#
This property holds Whether the line edit starts a drag if the user presses and moves the mouse on some selected text..
Dragging is disabled by default.
- Access functions:
dragEnabled
()setDragEnabled
(b)
- property PᅟySide6.QtWidgets.QLineEdit.echoMode: EchoMode#
This property holds The line edit’s echo mode..
The echo mode determines how the text entered in the line edit is displayed (or echoed) to the user.
The most common setting is Normal
, in which the text entered by the user is displayed verbatim. QLineEdit
also supports modes that allow the entered text to be suppressed or obscured: these include NoEcho
, Password
and PasswordEchoOnEdit
.
The widget’s display and the ability to copy or drag the text is affected by this setting.
By default, this property is set to Normal
.
See also
EchoMode
displayText()
- Access functions:
echoMode
()setEchoMode
(arg__1)
- property PᅟySide6.QtWidgets.QLineEdit.frame: bool#
This property holds Whether the line edit draws itself with a frame..
If enabled (the default), the line edit draws itself inside a frame. Otherwise, the line edit draws itself without any frame.
- property PᅟySide6.QtWidgets.QLineEdit.hasSelectedText: bool#
This property holds Whether there is any text selected..
hasSelectedText() returns true
if some or all of the text has been selected by the user. Otherwise, it returns false
.
By default, this property is false
.
See also
- Access functions:
- property PᅟySide6.QtWidgets.QLineEdit.inputMask: str#
This property holds The validation input mask..
Sets the QLineEdit
‘s validation mask. Validators can be used instead of, or in conjunction with masks; see setValidator()
. The default is an empty string, which means that no input mask is used.
To unset the mask and return to normal QLineEdit
operation, pass an empty string.
The input mask is an input template string. It can contain the following elements:
Mask Characters
Defines the Category of input characters that are considered valid in this position.
Meta Characters
Various special meanings (see details below).
Separators
All other characters are regarded as immutable separators.
The following table shows the mask and meta characters that can be used in an input mask.
Mask Character
Meaning
A
Character of the Letter category required, such as A-Z, a-z.
a
Character of the Letter category permitted but not required.
N
Character of the Letter or Number category required, such as A-Z, a-z, 0-9.
n
Character of the Letter or Number category permitted but not required.
X
Any non-blank character required.
x
Any non-blank character permitted but not required.
9
Character of the Number category required, such as 0-9.
0
Character of the Number category permitted but not required.
D
Character of the Number category and larger than zero required, such as 1-9.
d
Character of the Number category and larger than zero permitted but not required, such as 1-9.
#
Character of the Number category, or plus/minus sign permitted but not required.
H
Hexadecimal character required. A-F, a-f, 0-9.
h
Hexadecimal character permitted but not required.
B
Binary character required. 0-1.
b
Binary character permitted but not required.
Meta Character
Meaning
>
All following alphabetic characters are uppercased.
<
All following alphabetic characters are lowercased.
!
Switch off case conversion.
;c
Terminates the input mask and sets the blank character to c.
[ ] { }
Reserved.
\
Use
\
to escape the special characters listed above to use them as separators.
When created or cleared, the line edit will be filled with a copy of the input mask string where the meta characters have been removed, and the mask characters have been replaced with the blank character (by default, a space
).
When an input mask is set, the text()
method returns a modified copy of the line edit content where all the blank characters have been removed. The unmodified content can be read using displayText()
.
The hasAcceptableInput()
method returns false if the current content of the line edit does not fulfill the requirements of the input mask.
Examples:
Mask
Notes
000.000.000.000;_
IP address; blanks are
_
.
HH:HH:HH:HH:HH:HH;_
MAC address
0000-00-00
ISO Date; blanks are
space
>AAAAA-AAAAA-AAAAA-AAAAA-AAAAA;#
License number; blanks are
#
and all (alphabetic) characters are converted to uppercase.
To get range control (e.g., for an IP address) use masks together with validators
.
See also
maxLength
digitValue()
- Access functions:
inputMask
()setInputMask
(inputMask)
- property PᅟySide6.QtWidgets.QLineEdit.maxLength: int#
This property holds The maximum permitted length of the text..
If the text is too long, it is truncated at the limit.
If truncation occurs, any selected text will be unselected, the cursor position is set to 0, and the first part of the string is shown.
If the line edit has an input mask, the mask defines the maximum string length.
By default, this property contains a value of 32767.
See also
- Access functions:
maxLength
()setMaxLength
(arg__1)
- property PᅟySide6.QtWidgets.QLineEdit.modified: bool#
This property holds Whether the line edit’s contents has been modified by the user..
The modified flag is never read by QLineEdit
; it has a default value of false and is changed to true whenever the user changes the line edit’s contents.
This is useful for things that need to provide a default value but do not start out knowing what the default should be (for example, it depends on other fields on the form). Start the line edit without the best default, and when the default is known, if modified() returns false
(the user hasn’t entered any text), insert the default value.
Calling setText()
resets the modified flag to false.
- Access functions:
isModified
()setModified
(arg__1)
- property PᅟySide6.QtWidgets.QLineEdit.placeholderText: str#
This property holds The line edit’s placeholder text..
Setting this property makes the line edit display a grayed-out placeholder text as long as the line edit is empty.
Normally, an empty line edit shows the placeholder text even when it has focus. However, if the content is horizontally centered, the placeholder text is not displayed under the cursor when the line edit has focus.
By default, this property contains an empty string.
See also
- Access functions:
setPlaceholderText
(arg__1)
- property PᅟySide6.QtWidgets.QLineEdit.readOnly: bool#
This property holds Whether the line edit is read-only..
In read-only mode, the user can still copy the text to the clipboard, or drag and drop the text (if echoMode()
is Normal
), but cannot edit it.
QLineEdit
does not show a cursor in read-only mode.
By default, this property is false
.
See also
- Access functions:
isReadOnly
()setReadOnly
(arg__1)
- property PᅟySide6.QtWidgets.QLineEdit.redoAvailable: bool#
This property holds Whether redo is available..
Redo becomes available once the user has performed one or more undo operations on the text in the line edit.
By default, this property is false
.
- Access functions:
- property PᅟySide6.QtWidgets.QLineEdit.selectedText: str#
This property holds The selected text..
If there is no selected text, this property’s value is an empty string.
By default, this property contains an empty string.
See also
- Access functions:
selectedText
()
- property PᅟySide6.QtWidgets.QLineEdit.text: str#
This property holds The line edit’s text..
Setting this property clears the selection, clears the undo/redo history, moves the cursor to the end of the line, and resets the modified
property to false. The text is not validated when inserted with setText().
The text is truncated to maxLength()
length.
By default, this property contains an empty string.
- Access functions:
text
()setText
(arg__1)Signal
textChanged
(arg__1)
- property PᅟySide6.QtWidgets.QLineEdit.undoAvailable: bool#
This property holds Whether undo is available..
Undo becomes available once the user has modified the text in the line edit.
By default, this property is false
.
- Access functions:
- PySide6.QtWidgets.QLineEdit.ActionPosition#
This enum type describes how a line edit should display the action widgets to be added.
Constant
Description
QLineEdit.LeadingPosition
The widget is displayed to the left of the text when using layout direction
Qt::LeftToRight
or to the right when usingQt::RightToLeft
, respectively.QLineEdit.TrailingPosition
The widget is displayed to the right of the text when using layout direction
Qt::LeftToRight
or to the left when usingQt::RightToLeft
, respectively.See also
- PySide6.QtWidgets.QLineEdit.EchoMode#
This enum type describes how a line edit should display its contents.
Constant
Description
QLineEdit.Normal
Display characters as they are entered. This is the default.
QLineEdit.NoEcho
Do not display anything. This may be appropriate for passwords where even the length of the password should be kept secret.
QLineEdit.Password
Display platform-dependent password mask characters instead of the characters actually entered.
QLineEdit.PasswordEchoOnEdit
Display characters only while they are entered. Otherwise, display characters as with
Password
.See also
- PySide6.QtWidgets.QLineEdit.addAction(icon, position)#
- Parameters:
icon –
PySide6.QtGui.QIcon
position –
ActionPosition
- Return type:
This is an overloaded function.
Creates a new action with the given icon
at the position
.
- PySide6.QtWidgets.QLineEdit.addAction(action, position)
- Parameters:
action –
PySide6.QtGui.QAction
position –
ActionPosition
Adds the action
to the list of actions at the position
.
- PySide6.QtWidgets.QLineEdit.alignment()#
- Return type:
Combination of
Qt.AlignmentFlag
See also
Getter of property alignment
.
- PySide6.QtWidgets.QLineEdit.backspace()#
If no text is selected, deletes the character to the left of the text cursor, and moves the cursor one position to the left. If any text is selected, the cursor is moved to the beginning of the selected text, and the selected text is deleted.
See also
del()
- PySide6.QtWidgets.QLineEdit.clear()#
Clears the contents of the line edit.
- PySide6.QtWidgets.QLineEdit.completer()#
- Return type:
Returns the current QCompleter
that provides completions.
See also
- PySide6.QtWidgets.QLineEdit.copy()#
Copies the selected text to the clipboard, if there is any, and if echoMode()
is Normal
.
- PySide6.QtWidgets.QLineEdit.createStandardContextMenu()#
- Return type:
Creates the standard context menu, which is shown when the user clicks on the line edit with the right mouse button. It is called from the default contextMenuEvent()
handler. The popup menu’s ownership is transferred to the caller.
- PySide6.QtWidgets.QLineEdit.cursorBackward(mark[, steps=1])#
- Parameters:
mark – bool
steps – int
Moves the cursor back steps
characters. If mark
is true, each character moved over is added to the selection. If mark
is false, the selection is cleared.
See also
- PySide6.QtWidgets.QLineEdit.cursorForward(mark[, steps=1])#
- Parameters:
mark – bool
steps – int
Moves the cursor forward steps
characters. If mark
is true, each character moved over is added to the selection. If mark
is false, the selection is cleared.
See also
- PySide6.QtWidgets.QLineEdit.cursorMoveStyle()#
- Return type:
See also
Getter of property cursorMoveStyle
.
- PySide6.QtWidgets.QLineEdit.cursorPosition()#
- Return type:
int
See also
Getter of property cursorPosition
.
- PySide6.QtWidgets.QLineEdit.cursorPositionAt(pos)#
- Parameters:
pos –
PySide6.QtCore.QPoint
- Return type:
int
Returns the cursor position under the point pos
.
- PySide6.QtWidgets.QLineEdit.cursorPositionChanged(arg__1, arg__2)#
- Parameters:
arg__1 – int
arg__2 – int
This signal is emitted whenever the cursor moves. The previous position is given by oldPos
, and the new position by newPos
.
See also
- PySide6.QtWidgets.QLineEdit.cursorRect()#
- Return type:
Returns a rectangle that includes the line edit cursor.
- PySide6.QtWidgets.QLineEdit.cursorWordBackward(mark)#
- Parameters:
mark – bool
Moves the cursor one word backward. If mark
is true, the word is also selected.
See also
- PySide6.QtWidgets.QLineEdit.cursorWordForward(mark)#
- Parameters:
mark – bool
Moves the cursor one word forward. If mark
is true, the word is also selected.
See also
- PySide6.QtWidgets.QLineEdit.cut()#
Copies the selected text to the clipboard and deletes it, if there is any, and if echoMode()
is Normal
.
If the current validator disallows deleting the selected text, cut() will copy without deleting.
See also
- PySide6.QtWidgets.QLineEdit.del_()#
- PySide6.QtWidgets.QLineEdit.deselect()#
Deselects any selected text.
See also
- PySide6.QtWidgets.QLineEdit.displayText()#
- Return type:
str
Getter of property displayText
.
- PySide6.QtWidgets.QLineEdit.dragEnabled()#
- Return type:
bool
See also
Getter of property dragEnabled
.
- PySide6.QtWidgets.QLineEdit.echoMode()#
- Return type:
See also
Getter of property echoMode
.
- PySide6.QtWidgets.QLineEdit.editingFinished()#
This signal is emitted when the Return or Enter key is used, or if the line edit loses focus and its contents have changed since the last time this signal was emitted.
Note
If there is a validator()
or inputMask()
set on the line edit and enter/return is used, the editingFinished() signal will only be emitted if the input follows the inputMask()
and the validator()
returns QValidator::Acceptable.
- PySide6.QtWidgets.QLineEdit.end(mark)#
- Parameters:
mark – bool
Moves the text cursor to the end of the line unless it is already there. If mark
is true, text is selected towards the last position. Otherwise, any selected text is unselected if the cursor is moved.
See also
- PySide6.QtWidgets.QLineEdit.hasAcceptableInput()#
- Return type:
bool
Getter of property acceptableInput
.
- PySide6.QtWidgets.QLineEdit.hasFrame()#
- Return type:
bool
Getter of property frame
.
- PySide6.QtWidgets.QLineEdit.hasSelectedText()#
- Return type:
bool
Getter of property hasSelectedText
.
- PySide6.QtWidgets.QLineEdit.home(mark)#
- Parameters:
mark – bool
Moves the text cursor to the beginning of the line unless it is already there. If mark
is true, text is selected towards the first position. Otherwise, any selected text is unselected if the cursor is moved.
See also
- PySide6.QtWidgets.QLineEdit.initStyleOption(option)#
- Parameters:
option –
PySide6.QtWidgets.QStyleOptionFrame
Initialize option
with the values from this QLineEdit
. This method is useful for subclasses when they need a QStyleOptionFrame
, but don’t want to fill in all the information themselves.
See also
- PySide6.QtWidgets.QLineEdit.inputMask()#
- Return type:
str
See also
Getter of property inputMask
.
- PySide6.QtWidgets.QLineEdit.inputMethodQuery(property, argument)#
- Parameters:
property –
InputMethodQuery
argument – object
- Return type:
object
- PySide6.QtWidgets.QLineEdit.inputRejected()#
This signal is emitted when the user uses a key that is not considered to be valid input. For example, if using a key results in a validator’s validate() call to return Invalid. Another case is when trying to enter more characters beyond the maximum length of the line edit.
Note
This signal will still be emitted when only a part of the text is accepted. For example, if there is a maximum length set and the clipboard text is longer than the maximum length when it is pasted.
- PySide6.QtWidgets.QLineEdit.insert(arg__1)#
- Parameters:
arg__1 – str
Deletes any selected text, inserts newText
, and validates the result. If it is valid, it sets the new text as the new contents of the line edit.
- PySide6.QtWidgets.QLineEdit.isClearButtonEnabled()#
- Return type:
bool
Getter of property clearButtonEnabled
.
- PySide6.QtWidgets.QLineEdit.isModified()#
- Return type:
bool
Getter of property modified
.
- PySide6.QtWidgets.QLineEdit.isReadOnly()#
- Return type:
bool
Getter of property readOnly
.
- PySide6.QtWidgets.QLineEdit.isRedoAvailable()#
- Return type:
bool
Getter of property redoAvailable
.
- PySide6.QtWidgets.QLineEdit.isUndoAvailable()#
- Return type:
bool
Getter of property undoAvailable
.
- PySide6.QtWidgets.QLineEdit.maxLength()#
- Return type:
int
See also
Getter of property maxLength
.
- PySide6.QtWidgets.QLineEdit.paste()#
Inserts the clipboard’s text at the cursor position, deleting any selected text, providing the line edit is not read-only
.
If the end result would be invalid to the current validator
, nothing happens.
- PySide6.QtWidgets.QLineEdit.placeholderText()#
- Return type:
str
See also
Getter of property placeholderText
.
- PySide6.QtWidgets.QLineEdit.redo()#
Redoes the last operation if redo is available
.
- PySide6.QtWidgets.QLineEdit.returnPressed()#
This signal is emitted when the Return or Enter key is used.
Note
If there is a validator()
or inputMask()
set on the line edit, the returnPressed() signal will only be emitted if the input follows the inputMask()
and the validator()
returns QValidator::Acceptable.
- PySide6.QtWidgets.QLineEdit.selectAll()#
Selects all the text (highlights it) and moves the cursor to the end.
Note
This is useful when a default value has been inserted because if the user types before clicking on the widget, the selected text will be deleted.
See also
- PySide6.QtWidgets.QLineEdit.selectedText()#
- Return type:
str
Getter of property selectedText
.
- PySide6.QtWidgets.QLineEdit.selectionChanged()#
This signal is emitted whenever the selection changes.
See also
- PySide6.QtWidgets.QLineEdit.selectionEnd()#
- Return type:
int
Returns the index of the character directly after the selection in the line edit (or -1 if no text is selected).
- PySide6.QtWidgets.QLineEdit.selectionLength()#
- Return type:
int
Returns the length of the selection.
See also
- PySide6.QtWidgets.QLineEdit.selectionStart()#
- Return type:
int
Returns the index of the first selected character in the line edit (or -1 if no text is selected).
- PySide6.QtWidgets.QLineEdit.setAlignment(flag)#
- Parameters:
flag – Combination of
Qt.AlignmentFlag
See also
Setter of property alignment
.
- PySide6.QtWidgets.QLineEdit.setClearButtonEnabled(enable)#
- Parameters:
enable – bool
See also
Setter of property clearButtonEnabled
.
- PySide6.QtWidgets.QLineEdit.setCompleter(completer)#
- Parameters:
completer –
PySide6.QtWidgets.QCompleter
Sets this line edit to provide auto completions from the completer, c
. The completion mode is set using setCompletionMode()
.
To use a QCompleter
with a QValidator or inputMask
, you need to ensure that the model provided to QCompleter
contains valid entries. You can use the QSortFilterProxyModel to ensure that the QCompleter
‘s model contains only valid entries.
To remove the completer and disable auto-completion, pass a nullptr
.
See also
- PySide6.QtWidgets.QLineEdit.setCursorMoveStyle(style)#
- Parameters:
style –
CursorMoveStyle
See also
Setter of property cursorMoveStyle
.
- PySide6.QtWidgets.QLineEdit.setCursorPosition(arg__1)#
- Parameters:
arg__1 – int
See also
Setter of property cursorPosition
.
- PySide6.QtWidgets.QLineEdit.setDragEnabled(b)#
- Parameters:
b – bool
See also
Setter of property dragEnabled
.
Setter of property echoMode
.
- PySide6.QtWidgets.QLineEdit.setFrame(arg__1)#
- Parameters:
arg__1 – bool
See also
Setter of property frame
.
- PySide6.QtWidgets.QLineEdit.setInputMask(inputMask)#
- Parameters:
inputMask – str
See also
Setter of property inputMask
.
- PySide6.QtWidgets.QLineEdit.setMaxLength(arg__1)#
- Parameters:
arg__1 – int
See also
Setter of property maxLength
.
- PySide6.QtWidgets.QLineEdit.setModified(arg__1)#
- Parameters:
arg__1 – bool
See also
Setter of property modified
.
- PySide6.QtWidgets.QLineEdit.setPlaceholderText(arg__1)#
- Parameters:
arg__1 – str
See also
Setter of property placeholderText
.
- PySide6.QtWidgets.QLineEdit.setReadOnly(arg__1)#
- Parameters:
arg__1 – bool
See also
Setter of property readOnly
.
- PySide6.QtWidgets.QLineEdit.setSelection(arg__1, arg__2)#
- Parameters:
arg__1 – int
arg__2 – int
Selects text from position start
and for length
characters. Negative lengths are allowed.
See also
Setter of property text
.
- PySide6.QtWidgets.QLineEdit.setTextMargins(margins)#
- Parameters:
margins –
PySide6.QtCore.QMargins
Sets the margins
around the text inside the frame.
See also
- PySide6.QtWidgets.QLineEdit.setTextMargins(left, top, right, bottom)
- Parameters:
left – int
top – int
right – int
bottom – int
Sets the margins around the text inside the frame to have the sizes left
, top
, right
, and bottom
.
See also
- PySide6.QtWidgets.QLineEdit.setValidator(arg__1)#
- Parameters:
arg__1 –
PySide6.QtGui.QValidator
Sets the validator for values of line edit to v
.
The line edit’s returnPressed()
and editingFinished()
signals will only be emitted if v
validates the line edit’s content as Acceptable. The user may change the content to any Intermediate value during editing, but will be prevented from editing the text to a value that v
validates as Invalid.
This allows you to constrain the text that will be stored when editing is done while leaving users with enough freedom to edit the text from one valid state to another.
To remove the current input validator, pass nullptr
. The initial setting is to have no input validator (any input is accepted up to maxLength()
).
See also
validator()
hasAcceptableInput()
QIntValidatorQDoubleValidatorQRegularExpressionValidator
Getter of property text
.
- PySide6.QtWidgets.QLineEdit.textChanged(arg__1)#
- Parameters:
arg__1 – str
This signal is emitted whenever the text changes. The text
argument is the new text.
Unlike textEdited()
, this signal is also emitted when the text is changed programmatically, for example, by calling setText()
.
Notification signal of property text
.
- PySide6.QtWidgets.QLineEdit.textEdited(arg__1)#
- Parameters:
arg__1 – str
This signal is emitted whenever the text is edited. The text
argument is the new text.
Unlike textChanged()
, this signal is not emitted when the text is changed programmatically, for example, by calling setText()
.
- PySide6.QtWidgets.QLineEdit.textMargins()#
- Return type:
Returns the widget’s text margins.
See also
- PySide6.QtWidgets.QLineEdit.undo()#
Undoes the last operation if undo is available
. Deselects any current selection, and updates the selection start to the current cursor position.
- PySide6.QtWidgets.QLineEdit.validator()#
- Return type:
Returns a pointer to the current input validator, or None
if no validator has been set.
See also